Application Scenario: The most front-end is an nginx server, all the static content is handled by Nginx, and all the PHP requests are distributed to several downstream servers running the PHP fastcgi daemon, which can be used in an inexpensive scheme to achieve the allocation of system load, Extend the load capacity of the system.
the IP addresses of the three PHP fastcgi servers are:
172.16.236.110, 172.16.236.111, 172.16.236.112
when running the PHP fastcgi process, you need to let php-cgi hear the server's LAN address (as shown above), rather than the local address (127.0.0.1), which is generally listening. Take 172.16.236.110 This server as an example:
/usr/local/php5/bin/php-cgi-b 172.16.236.110:9000
If you are using PHP-FPM to manage php-fcgi, then you need to modify the configuration of the PHP-FPM:
vi/usr/local/php5/etc/php-fpm.conf
Find this configuration item (where the address may need to be adjusted according to your own environment)
<value name= "listen_address" >127.0.0.1:9000</value>
modified to:
<value name= "listen_address" >172.16.236.110:9000</value>
after you have finished modifying, restart your php-fpm process.
then follow the steps above to modify the other PHP fastcgi servers in turn.
Modify Nginx configuration below
vi/usr/local/nginx/conf/nginx.conf
add a configuration similar to the following in the HTTP segment of the configuration file:
upstream myfastcgi {
server 172.16.236.110 weight=1;
server 172.16.236.111 weight=1;
server 172.16.236.112 weight=1;
}
Of Course each FASTCGI server weight can be arbitrarily adjusted, I have set 1 is the same weight
then find the original nginx about the PHP fastcgi configuration, such as:
Location ~ \.php$ {
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
include Fastcgi_params;
}
Replace the Fastcgi_pass paragraph with the following:
Fastcgi_pass myfastcgi;
This article is from the Linux OPS blog, so be sure to keep this source http://zhumy.blog.51cto.com/11647651/1826889
One nginx to multiple fastcgi