手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

RedHat 5.4下Web服务器架构之源码构建LNMP环境

[日期:2012-10-16] 来源:Linux社区  作者:shuiyong [字体:大 中 小]

2.1.3、源码安装PHP依赖程序包:

#安装PHP前首先要安装几个源码包依赖:libmcrypt mhash mcrypt

#这里我将下载的包放到/lnmp /目录下,安装过程中若出现错误,可以直接#跳过,这里不会影响后续过程

[root@shuiyong MySQL]# cd /lnmp/

[root@shuiyong lnmp]# tar -jxvf libmcrypt-2.5.8.tar.bz2 -C /usr/src/

[root@shuiyong lnmp]# cd /usr/src/libmcrypt-2.5.8/

[root@shuiyong libmcrypt-2.5.8]# ./configure

[root@shuiyong libmcrypt-2.5.8]# make && make install

[root@shuiyong mysql]# cd /lnmp/

[root@shuiyong lnmp]# tar -jxvf mhash-0.9.9.9.tar.bz2 -C /usr/src/

[root@shuiyong lnmp]# cd /usr/src/mhash-0.9.9.9/

[root@shuiyong mhash-0.9.9.9]# ./configure

[root@shuiyong mhash-0.9.9.9]# make && make install

[root@shuiyong mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.* /usr/lib/

[root@shuiyong mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt* /usr/lib

#这两个包安装完成后要把动态链接库做一个软连接到/usr/lib,以为接下来的#mcrypt依赖于这两个包,安装mcrypt包:

[root@shuiyong mhash-0.9.9.9]# cd /lnmp/

[root@shuiyong lnmp]# tar zxvf mcrypt-2.6.8.tar.gz -C /usr/src/

[root@shuiyong lnmp]# cd /usr/src/mcrypt-2.6.8/

[root@shuiyong mcrypt-2.6.8]# ./configure

[root@shuiyong mcrypt-2.6.8]# make && make install

#安装其它依赖包,发现很多已经安装,不影响后续过程:

[root@shuiyong mcrypt-2.6.8]# yum -y install libxml2-devel curl-devel libpng-devel openldap-devel

2.1.4、源码安装PHP

#使用nginx调用php的时候使用fpm的方式,在php 5.4中加入了对php-fpm

#的支持,所以就不需要打补丁了.以下显示安装PHP过程:

#解压mysql的主程序文件,使用tar –jxvf,并使用-C指定解压目录:

[root@shuiyong mcrypt-2.6.8]# cd /lnmp/

[root@shuiyong lnmp]# tar -jxvf php-5.4.0.tar.bz2 -C /usr/src/

[root@shuiyong lnmp]# cd /usr/src/php-5.4.0/

#进行预编译(配置):(各项配置说明略)

[root@shuiyong php-5.4.0]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-zlib --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --with-curl --with-curlwrappers --enable-fpm --enable-fastcgi --with-mcrypt --with-gd --with-openssl --with-mhash --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc -enable-zip --enable-soap

#预编译完成后就可以进行编译和安装:

[root@shuiyong php-5.4.0]# make && make install

2.1.5、使能nginx调度phphemysql

#置php和nginx能运行php网站,首先为php创建配置文件:

[root@shuiyong php-5.4.0]# cp php.ini-production /usr/local/php/php.ini

 

[root@shuiyongphp-5.4.0]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

[root@shuiyong php-5.4.0]# ln -s /usr/local/php/bin/php /usr/bin/

#配置php-fpm,编辑php-fpm.conf,找到listen那一行,修改成如下内容:

[root@shuiyong php-5.4.0]# vim /usr/local/php/etc/php-fpm.conf

143 listen = /var/run/php-fpm/php-fpm.sock

 

 

#创建php-fpm目录,启动php-fpm

[root@shuiyong php-5.4.0]# mkdir /var/run/php-fpm

[root@shuiyong php-5.4.0]# cd /usr/local/php/sbin/

[root@shuiyong sbin]# ls

php-fpm

[root@shuiyong sbin]# ./php-fpm

#然后配置nginx,编辑nginx配置文件

[root@shuiyong sbin]# cd /usr/src/php-5.4.0/

[root@shuiyong php-5.4.0]# vim /etc/nginx/nginx.conf

#修改45行内容,增加index.php,添加index.php的首页文件选项

45index index.php index.html index.htm;

#添加48—54行

48 location ~ \.php$ {

49fastcgi_passunix:/var/run/php-fpm/php-fpm.sock;

50fastcgi_indexindex.php;

51fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;

52include fastcgi_params;

53include fastcgi.conf;

54 }

 

 

#修改完毕后保存退出重启nginx:

[root@shuiyong php-5.4.0]# service nginx restart

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

Stopping nginx:[OK]

Starting nginx:[OK]

 

2.1、  测试LNMP环境

#增加网页测试文件:编辑nginx的配置文件使识别index.php文件

[root@shuiyong html]# cd /usr/html/

[root@shuiyong html]# ll

total 16

-rw-r--r-- 1 root root 383 Oct 16 13:36 50x.html

-rw-r--r-- 1 root root 216 Oct 16 14:47 index.html

linux
相关资讯       Web服务器  LNMP  LNMP源码安装 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款