测试环境
Linux 2.6.18
nginx-1.0.4?http://www.nginx.org/
php-5.3.6?http://www.php.net/
一,安装Nginx
wget http://nginx.org/download/nginx-1.0.4.tar.gz
tar -zxvf nginx-1.0.4.tar.gz
cd nginx-1.0.4
./configure --prefix=/data/apps/nginx-1.0.4
make && make install
二,安装php-5.3.6
wget http://www.php.net/get/php-5.3.6.tar.gz/from/a/mirror
tar -zxvf php-5.3.6.tar.gz
cd php-5.3.6
./configure --prefix=/data/apps/php5.3.6 --enable-mbstring --with-mcrypt --with-mhash?--enable-fpm
make && make install
cd /data/apps/php5.3.6/etc/
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
去掉下列变量前面的注释,以避免启动php-fpm时报错
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
三,整合Nginx和php
编辑Nginx配置文件,其中`/home/php`为站点根目录
nginx 配置文件中增加?
?
- location ~ .*\.php$ {
- ? ? ? ? ? root ? ? ? ? ? /home/php;
- ? ? ? ? ? index index.html index.htm index.php;
- ? ? ? ? ? fastcgi_pass ? 127.0.0.1:9000;
- ? ? ? ? ? fastcgi_index ?index.php;
- ? ? ? ? ? fastcgi_param ?SCRIPT_FILENAME ?/home/php$fastcgi_script_name;
- ? ? ? ? ?include ? ? ? ?fastcgi_params;
- ? ? ? ? ?##include /usr/local/nginx/conf/fastcgi_params;
- }
?
四,启动php-fpm & Nginx
/data/apps/php5.3.6/sbin/php-fpm &
/data/apps/nginx-1.0.4/sbin/nginx &
五,小结
php5.3.3以上的版本集成了php-fpm,所以安装步骤比较简单,看来Nginx真的有传说中的魅力,现在连php都向其靠拢了。
Nginx通过php-fpm监听的默认9000端口来解析php请求。
?
?
====关闭 和启动========
killall php-fpm
killall nginx
?
/home/pt/php-5.5.11/sbin/php-fpm & /usr/local/nginx/sbin/nginx &
?
参考:http://www.codesky.net/article/201202/172806.html
http://www.jb51.net/article/26597.htm
http://djc84.blog.163.com/blog/static/9446729320121133739333/