码迷,mamicode.com
首页 > Web开发 > 详细

Nginx服务器和PHP服务器分布式部署

时间:2015-03-06 06:23:58      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:nginx linux php 分离 分开 分布式

1)设定IP

Nginx服务器:192.168.1.10     nginx1.6.2

PHP服务器:192.168.1.11      php5.3.29


2)安装好NginxPHP,其中Nginx服务和PHP-FPM服务正常开启

 

3)配置文件的写法至关重要,新手的大坑,如下写:

 

  • nginx.conf关键的地方是

 

        location ~ \.php$ {

            root           html;

            fastcgi_pass   192.168.1.11:9000;

            fastcgi_index  index.php;

            fastcgi_param SCRIPT_FILENAME /application/nginx/html/$fastcgi_script_name;

            include        fastcgi_params;

        }

 

  • 关键点说明:大坑的地方是这条

 

fastcgi_param  SCRIPT_FILENAME/application/nginx/html/$fastcgi_script_name;

 

        /application/nginx/html/  这个路径不要以为是nginx网站的根目录路径,其实是PHP服务器的目录,这个目录要建立在PHP服务器上,然后把.php的文件放入其中,放到nginx的网站根目录是没用的,百分之百出现file not found。这个目录的路径可以写成和nginx网站根目录的路径一样。

 

  • php-fpm.conf关键的地方是

 

把这行注释去掉listen.allowed_clients = ,填写上nginx服务器的IP

 

listen.allowed_clients= 192.168.1.10

 

把侦听那里的注释去掉,改成:


; Note: This valueis mandatory.

listen= 192.168.1.11:9000

 

重启php-fpm,然后在php服务器上的网站根目录/application/nginx/html/放入phpinfo.php,就能成功打开phpinfo.php了。


本文出自 “biohazard2k” 博客,请务必保留此出处http://biohazard2k.blog.51cto.com/68212/1617753

Nginx服务器和PHP服务器分布式部署

标签:nginx linux php 分离 分开 分布式

原文地址:http://biohazard2k.blog.51cto.com/68212/1617753

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!