日期:2014-05-16  浏览次数:20713 次

linux下安装nginx1.2.3和php5.4.4

安装nginx1.2.3

第一步:解压

[root@test02 software]# tar zxvf nginx-1.2.3.tar.gz

?

第二步:编译

[root@test02 nginx-1.2.3]# ./configure --prefix=/usr/local/nginx-1.2.3

[root@test02 nginx-1.2.3]# make

[root@test02 nginx-1.2.3]# make install

?

如果提示缺少pcre库,执行yum install pcre* 来安装pcre 和pcre-devel

?

?

第三步:运行

[root@test02 nginx-1.2.3]# cd /usr/local/nginx-1.2.3/
[root@test02 nginx-1.2.3]# ./sbin/nginx &

?

安装php5.4.4

第一步:解压

[root@test02 software]# tar zxf php-5.4.4.tar.gz

?

第二步:编译

[root@test02 php-5.4.4]# ./configure --prefix=/usr/local/php-5.4.4 --enable-fpm

[root@test02 php-5.4.4]# make

[root@test02 php-5.4.4]# make install

?

第三步:复制php.ini

复制php.ini-production 到 /usr/local/php-5.4.4/lib/php.ini

?

[root@test02 php-5.4.4]# cd /usr/local/php-5.4.4/

[root@test02 php-5.4.4]# cp /opt/software/php-5.4.4/php.ini-production lib/php.ini

?

修改php-fpm.conf

?

[root@test02 php-5.4.4]# cd etc/

[root@test02 etc]# mv php-fpm.conf.default php-fpm.conf

?

找到 ;pm.status_path = /status 去掉前面的分号

?

新增/home/www目录用于存放php文件

?

[root@test02 nginx-1.2.3]# mkdir /home/www
[root@test02 nginx-1.2.3]# chown -R nobody:nobody /home/www

?

修改nginx.conf将php那段改为

?# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
??????? #
??????? location ~ \.php$ {
??????????? root????????? /home/www;
??????????? fastcgi_pass?? 127.0.0.1:9000;
??????????? fastcgi_index? index.php;
??????????? fastcgi_param? SCRIPT_FILENAME? /home/www$fastcgi_script_name;
??????????? include??????? fastcgi_params;
??????? }

?

?????? location ~ ^/status$ {
??????????? fastcgi_pass 127.0.0.1:9000;
??????????? fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
??????????? include fastcgi_params;
??????? }

?

??????? location ~ status.html$ {
?????????? root /home/www;
??????? }

?

复制status.html 到 /home/www 目录

?

[root@test02 php-5.4.4]# cp /opt/software/php-5.4.4/sapi/fpm/status.html /home/www/

?

运行fpm

?

[root@test02 php-5.4.4]# ./sbin/php-fpm

?

?

新建phpinfo.php 内容为 <?php phpinfo();?>

?

访问http://192.168.1.107:9090/phpinfo.php

访问http://192.168.1.107:9090/status.html

?

?

?

?