连接到Unix:/var/run/php5-fpm.sock失败.我的设置有什么问题? [英] Connect to unix:/var/run/php5-fpm.sock failed. What is wrong with my setup?

查看:852
本文介绍了连接到Unix:/var/run/php5-fpm.sock失败.我的设置有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在DigitalOcean上具有2GB的VPS,并且正在Debian 7下使用NGINX,php-fpm和unix套接字托管WordPress 3.9.1.

I have a 2GB VPS on DigitalOcean and I am hosting WordPress 3.9.1 under Debian 7 with NGINX, php-fpm and unix socket.

运行良好,直到上周它开始显示"502网关错误"错误.我检查了日志,发现:

It was working perfectly until last week it started showing a "502 bad gateway" error. I checked the logs and found that:

php5-fpm日志显示已达到pm.max_children并 nginx日志显示以下内容:

php5-fpm log is showing pm.max_children was reached and nginx log is showing the following:

[错误] 3239#0:* 15188与unix的connect():/var/run/php5-fpm.sock在连接到上游,客户端:xxx.xxx.xxx.xxx时失败(11:资源暂时不可用) ,服务器:my.domain,请求:"POST/xmlrpc.php HTTP/1.0",上游:"fastcgi://unix:/var/run/php5-fpm.sock:",主机:"xxx.xxx.xxx" .xxx"

[error] 3239#0: *15188 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: my.domain, request: "POST /xmlrpc.php HTTP/1.0", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "xxx.xxx.xxx.xxx"

我用不同的设置手动更改了pm,但没有运气.每次更改后,我总是重新启动守护程序.

I manually changed pm with different settings with no luck. I always restart the daemons after every change.

pm设置为:

pm = dynamic 
pm.max_children = 100 
pm.start_servers = 10 
pm.min_spare_servers = 10 
pm.max_spare_servers = 10 
pm.max_requests = 200

www.conf启用了listen = /var/run/php5-fpm.sock.

有类似经历的人吗?

推荐答案

第一个问题是您指定100个max_children,这对于2GB来说确实很高.我会把它丢给25个孩子.在这里查看我的帖子,了解如何针对您的设置优化php-fpm配置:

The first problem is you are specifying 100 max_children, that is awfully high for 2GB. I would drop it to 25 children. See my post here on how to optimise your php-fpm configuration for your setup:

此外,使用unix套接字的速度稍快一些,因为它为您提供了直接的网络访问权限,而没有任何TCP/IP开销.不利的一面是,它的可扩展性不如TCP/IP.当套接字耗尽时,Nginx将抛出502错误.在这种情况下,您可以调整OS设置以适应更大的连接池,也可以切换到TCP/IP.

Also, using unix sockets is slightly faster since it provides you direct network access without any TCP/IP overhead. On the down side, it is not as scalable as TCP/IP. Nginx will throw 502 errors when the sockets have been depleted. In such a case you can either tweak the OS settings to accommodate the larger connection pool or just switch to switch to TCP/IP.

在您的fastcgi conf更改中:

In your fastcgi conf change:

fastcgi_pass unix:/var/run/php5-fpm.sock;

收件人:

fastcgi_pass 127.0.0.1:9000;

请注意,端口9000是php-fpm中设置的默认端口,如果您已将php-fpm更改为侦听另一个端口,则用该值交换9000.确保重新启动php-fpm和nginx.

Note that port 9000 is the default port set in php-fpm, if you have changed php-fpm to listen on another port then swap 9000 with that value. Make sure you restart both php-fpm and nginx.

现在,如果完成所有这些操作后,您仍然无法使它正常工作,并且 free -m 返回高内存使用率,那么该是时候向服务器中添加更多ram了.

Now, if after all of this, you still cannot get it to work and free -m returns high memory usage, then it is time to add more ram to your server.

这篇关于连接到Unix:/var/run/php5-fpm.sock失败.我的设置有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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