The most front end of the application 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 to allocate the load of the system in an inexpensive scheme. 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
Perhaps you use spawn-fcgi to start the php-fcgi, then that is the case (for reference, in fact, it is to modify the listening address and port can be):
/usr/local/lighttpd/bin/spawn-fcgi-f/usr/local/php5/bin/php-cgi-a 172.16.236.110-p 9000
Or perhaps you are using PHP-FPM to manage php-fcgi, then you need to modify the PHP-FPM configuration
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.
PHP work for the time being these, the following changes nginx.
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;
}
I here three PHP fastcgi server weights are the same, so the weight value is 1, if your PHP fastcgi server need to sub-primary, then you can adjust its weight value to achieve the goal. For example, the first server-based, the other two supplemented, it is this:
Upstream myfastcgi {
Server 172.16.236.110 weight=1;
Server 172.16.236.111 weight=2;
Server 172.16.236.112 weight=2; }
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;
The myfastcgi is the name of the PHP fastcgi equalizer that was just configured above.
When you're done, restart Nginx