您的位置:首页 > 运维架构 > Linux

linux 6.6编译安装LNMP

2015-08-26 00:38 666 查看
LNMP+memcached今天我们自己的项目易可在线社团管理平台换血液,从LAMP转移至LNMP,几个同学搞的小项目,就一个云平台,真心需求发展。今天也是重新搭建了一遍,小弟我一个人管理我们平台,真心充实,学到多少就尽量跟大家分享吧。今日不准备做太多排版,大家见谅。
环境准备rhel 6.6_x86_64DevelopmentToolspcre pcre-develzlib zlib-developenssl openssl-devellibxml2 libxml2-devellibcurl libcurl-devellibevent-2.0.22-stable.tar.gzlibmcrypt-2.5.7-1.2.el6.rf.x86_64.rpmlibmcrypt-devel-2.5.7-1.2.el6.rf.x86_64.rpmmhash-devel-0.9.9-1.el6.rf.x86_64.rpmmhash-0.9.9-1.el6.rf.x86_64.rpmxcache-3.2.0.tar.gzphp-5.6.8.tar.bz2pcre-8.35.tar.gznginx-1.6.3.tar.gzmysql-5.6.24-linux-glibc2.5-x86_64.tar.gzmemcache-2.2.6.tgzmemcached-1.4.24.tar.gznginx-1.6.3这些包都在这里密码(9663)一、点击这里编译安装mysqlhttp://gumpping.blog.51cto.com/9811308/1655520#T3[b]------------------------------------------------->mysql server完成[/b]二、安装nginx 特性在这里
#groupadd -r -g 108 nginx#useradd -r -g nginx nginx#tar -xf nginx-1.6.3#./configure   --prefix=/usr   --sbin-path=/usr/sbin/nginx   --conf-path=/etc/nginx/nginx.conf   --error-log-path=/var/log/nginx/error.log   --http-log-path=/var/log/nginx/access.log  --with-file-aio  --pid-path=/var/run/nginx/nginx.pid    --lock-path=/var/lock/nginx.lock   --user=nginx   --group=nginx   --with-http_ssl_module   --with-http_flv_module  --with-http_stub_status_module   --with-http_gzip_static_module   --http-client-body-temp-path=/var/tmp/nginx/client/   --http-proxy-temp-path=/var/tmp/nginx/proxy/   --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/   --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi   --http-scgi-temp-path=/var/tmp/nginx/scgi   --with-pcre#make && make install
添加服务脚本/etc/rc.d/init.d/nginx至访问列表在这里的nginx.txt(访问密码 9663)
#chmod +x /etc/rc.d/init.d/nginx#chkconfig --add nginx#chkconfig nginx on#service nginx start
[b]------------------------------------------------->nginx webserver完成[/b]三、安装php 官方文档1.编译安装路径选择默认,sapi选择fast-cgi(php-fpm是fast-cgi的进程管理器)GD模块是我们为申请二维码以及其他图形类处理安装的模块。配置文件路径:/etc/php/和/etc/php/php.d/
#tar -xf php-5.6.8.tar.gz#cd php-5.6.8# ./configure --enable-fpm --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt --with-bz2 --with-curl --with-gd --with-config-file-path=/etc/php/ --with-config-file-scan-dir=/etc/php/php.d/#make && make install
2.提供配置文件
# cp php.ini-production /etc/php/php.ini
3.提供php-fpm的配置文件
# cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf# vim /usr/local/etc/php-fpm.conf 根据需求配置
4.提供php-fpm的服务脚本
#cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
5.将其加入服务列表,启动(过程略)6.php加速器(xcache)简单来说就是php的opcode缓存器。不同进程对一个相同.php资源的请求解释完成后,将解释结果缓存,以备其他进程直接使用。详情参考xcache的官方文档
#tar xcache-3.2.0.tar.gz#cd xcache-3.2.0#phpize#./configure --enable-xcache --with-php-config=/usr/local/bin/php-config#make && make install#cp xcache.ini /etc/php/php.d/xcache.ini#service php-fpm restart
7.验证方法有二:其一phpinfo();其二# php -m[Zend Modules]XcacheXcache Cacher8.注意:这种编译不易版本搭配,编译之前多看官方文档,看看哪个版本更适合你用的phphttp://xcache.lighttpd.net/wiki/Release-3.2.0,用php5.6的只能选择xcache3.2.03.1.x只支持到5.5。还有xcache3.2.0的xcache.ini配置文件已经不支持zend_extension选项常见的xcache问题解答问题解答http://xcache.lighttpd.net/wiki/Faq[b]------------------------------------------------->php-fpm+xcache 完成[/b]四、OK,php+php-fpm+xcache完成!下面开始整合php+nginx
添加index.php索引:location / {root html;index index.html index.htm index.php;}取消注释行:location ~ \.php$ {root           /web/appserv/;fastcgi_pass   127.0.0.1:9000;fastcgi_index  index.php;fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;include        fastcgi_params;}
[b]------------------------------------------------->LNMP 完成[/b]五、安装memcached服务器客户端连接memcached服务器必须使用sasl认证,亦即libmemcached要开启sasl选项.(yum install -y libmemcached-devel)安装:先下载memcached-1.4.24.tar.gz
#tar -xf memcached-1.4.24.tar.gz#cd memcached-1.4.24.tar.gz#./configure --with-libevent=/usr#make && make install
简介,默认监听本机端口的11211端口.memcached----高性能分布式内存对象缓存系统,用于被用于降低数据库的压力而提高动态web应用的响应速度。跟memcached服务端交互的接口由libmemcached提供。也就是说,客户端想使用memcached服务器,就必须有libmemcached库。另外memcached处理socket时候要使用libevent,咱门此前已经安装过了,6.6上只要yum安装就行检查下lib库就知道有没有 ls /usr/lib | grep libevent 或者rpm -qla libevent。
memcached命令-d启动此脚本为一个守护进程-m分配给memcache使用的内存数量,单位是MB-u是运行memcache的用户,默认为root-l指定监听服务器的IP地址,-p指定端口-c选项是最大运行 的并发连接数。默认是1024,根据负载调节-P是设置保存memcache的pid文件可以启动多个守护进程,但是端口不能重复。
添加memcached脚本至服务列表(密码9663)(过程同上)
service memcached start
[b]------------------------------------------------->memcache server启动[/b]六、安装Memcache的PHP扩展 | 安装:(官方文档)Memcache模块提供了对memcache server很便捷的面向过程及其面向对象的接口。memcache和memcached同样有session处理器(默认开启选用disable-memcache-session可以关闭session支持)。下载memcache-2.2.6.tar.gz
# tar -xf memcache-2.2.6.tar.gz# cd memcache-2.2.6# phpize# ./configure --enable-memcache --with-php-config=/usr/local/bin/php-config --with-zlib# make && make install# vim /etc/php.d/memcache.soextension=memcache.so
PECL(memcache)扩展和xcache一样,都是没有被PHP直接扩展,需要维护人员手动将其编译至php中。到此php的memcached扩展基本就安装完成了[b]------------------------------------------------->memcache 客户端完成[/b]根据自己IP,赶紧测试!
<?php$mem = new Memcache;$mem->connect("192.168.168.201", 11211)  or die("Could not connect");$version = $mem->getVersion();echo "Server's version: ".$version."<br/>\n";$mem->set('testkey', 'Hello World', 0, 600) or die("Failed to save data at the memcached server");echo "Store data in the cache (data will expire in 600 seconds)<br/>\n";$get_result = $mem->get('testkey');echo "$get_result is from memcached server.";?>
如果能正常显示hello,world is from memcached server就配置成功很鸡冻有木有??特别鸣谢:http://nginx.org/http://www.php.net/http://www.mysql.com/http://xcache.lighttpd.net/http://www.ccvita.com/257.htmlhttp://www.magedu.com本文出自 “没有进步就是退步” 博客,请务必保留此出处http://gumpping.blog.51cto.com/9811308/1688295
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: