nginx负载均衡可以查考:Nginx负载均衡

配置php-fpm1和php-fpm2的www.conf配置文件

主要设计到配置的是listen和listen.allowed_clients listen代表的php-fpm监听的IP地址和端口 listen.allowed_clients代表使用局域网的IP地址而不是默认的127.0.0.1 #配置nginx服务器的IP地址

#192.168.0.11 www.conf
listen = 192.168.0.11:9000
listen.allowed_clients = 192.168.0.6
#192.168.0.12 www.conf
listen = 192.168.0.12:9000
listen.allowed_clients = 192.168.0.6

配置好之后需要重载配置 systemctl reload php56-php-fpm.service

配置nginx的nginx.conf文件
#nginx.conf   192.168.0.6
#只粘贴负载的配置
http{
    upstream phpserver{
        server 192.168.0.11:9000;
        server 192.168.0.12:9000;
    }
    server{
        listen 80;
        server_name www.ywcsb.vip;
        location / {
            root /usr/share/nginx/html;
            index index.html index.htm index.php;
        }
        locatin ~\.(js|css|png|jpg|jpeg|gif|ico)$ {
            root /usr/share/nginx/html;
            expires 1d;
        }
        locatin ~\.php$ {
            fastcgi_pass phpserver;
            root /usr/share/nginx/html;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}
同步php文件

由于fpm需要寻找每台机器下面的/usr/share/nginx/html目录,所以192.168.0.11-12 两台机上部署相同的代码,可以考虑使用nfs保持两台服务器上面的代码是相同的。