nginx负载均衡upstream参数配置

孤街醉人 提交于 2020-01-06 07:49:13

一定要注意两台机器能够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;
    }

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!