nginx-php-fpm集群 [英] nginx - php-fpm cluster

查看:51
本文介绍了nginx-php-fpm集群的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3台php-fpm服务器和1台nginx服务器,我想在其中使用nginx服务器对php-fpm进行负载平衡.

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

php-fpm服务器1-192.168.10.31php-fpm server2-192.168.10.32php-fpm server3-192.168.10.33

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

nginx-服务器-192.168.10.12

nginx - server - 192.168.10.12

我在nginx服务器上的配置为;

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;
}

但是我的问题是,我应该在哪里定义webroot [root/path/to/webfiles]

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

由于在nginx服务器[192.168.10.12]上,访问日志显示找不到文件-404.我应该在哪里保存网站php文件?在Nginx服务器或php服务器上?还是同时在Nginx和php服务器中使用?

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?

推荐答案

这是一个古老的问题,但是对于任何使用此工具的人,我都会在这里给出答案.

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

罗比·阿夫里尔(Robbie Averill)的评论是正确的.您应该同时在Nginx和PHP服务器上托管文件.您可以使用NFS共享来执行此操作,但这可能会使速度变慢.

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.

要解决此问题,您可以在nginx服务器上更新代码,然后rsync到php服务器.您可以轻松构建一个bash脚本,其功能类似于:

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/

当然,您希望将其包含在一个bash脚本中,该脚本用于更新代码并同步php计算机.

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

这篇关于nginx-php-fpm集群的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆