nginx - php-fpm cluster

我们两清 提交于 2021-02-07 20:14:14

问题


I have a three php-fpm servers, and a one nginx server, where I want to loadbalance php-fpm using nginx server.

php-fpm server1 - 192.168.10.31 php-fpm server2 - 192.168.10.32 php-fpm server3 - 192.168.10.33

nginx - server - 192.168.10.12

My Configuration on nginx server was;

upstream php_backend {
  server 192.168.10.31:9000;
  server 192.168.10.32:9000;
  server 192.168.10.33:9000;
}

location ~ \.php$ {
fastcgi_pass php_backend;
}

But my problem is, where should I define the webroot [ root /path/to/webfiles ]

Because on nginx server [ 192.168.10.12 ], access log says file not found - 404. Where should I keep website php files? On nginx server or php servers? or in both nginx and php servers?


回答1:


This is kind of an old question, but I'll give my answer here for anyone googling this.

Robbie Averill's comment is correct. You should host your files both on Nginx and PHP servers. You can do this with an NFS share, but this might slow things down.

To work around this you could update your code on the nginx server and then rsync to the php servers. You could easily build a bash script that does something like:

rsync -avzp -e ssh /srv/www/ svc_internal@php.insypro.com:/srv/www/
rsync -avzp -e ssh /srv/www/ svc_internal@php2.insypro.com:/srv/www/
rsync -avzp -e ssh /srv/www/ svc_internal@php3.insypro.com:/srv/www/

Of course, you'd want to include this in one bash script that does the updating of your code, and synchronises the php machines.



来源:https://stackoverflow.com/questions/37402788/nginx-php-fpm-cluster

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