One nginx to multiple fastcgi

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.