Home > Backend Development > PHP Tutorial > nginx调整php

nginx调整php

WBOY
Release: 2016-06-13 11:55:37
Original
930 people have browsed it

nginx整合php

测试环境

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 配置文件中增加?

?

  1. location ~ .*\.php$ {
  2. ? ? ? ? ? root ? ? ? ? ? /home/php;
  3. ? ? ? ? ? index index.html index.htm index.php;
  4. ? ? ? ? ? fastcgi_pass ? 127.0.0.1:9000;
  5. ? ? ? ? ? fastcgi_index ?index.php;
  6. ? ? ? ? ? fastcgi_param ?SCRIPT_FILENAME ?/home/php$fastcgi_script_name;
  7. ? ? ? ? ?include ? ? ? ?fastcgi_params;
  8. ? ? ? ? ?##include /usr/local/nginx/conf/fastcgi_params;
  9. }

?

四,启动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/

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template