nginx负载均衡upstream参数配置

一定要注意两台机器能够telnet 访问通过  如果不能通过则两台机器都执行一下 iptables -F

机器A:

php-fpm配置
[www]
user = www
group = www
listen = 127.0.0.1:9001
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

[www]
user = www
group = www
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

 

 

 

机器A nginx.conf配置

upstream backend{
      server  127.0.0.1:9000 weight=1;
      server  127.0.0.1:9001 weight=2;
      server  192.168.137.111:9000 weight=3;
      keepalive 3072;
}

    location ~ .*\.php
    {
            fastcgi_pass backend;
            fastcgi_index index.php;
            include fastcgi.conf;
    }

 

 

机器B php-fpm.conf配置


[www]
user = www
group = www
listen = 192.168.137.111:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
 

机器B nginx.conf配置

    location ~ .*\.php
    {
        fastcgi_pass 192.168.137.111:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
    }

你可能感兴趣的:(nginx负载均衡upstream参数配置)