在我的ubuntu 12.10服务器上,我将PHP升级到5.5.在我的wordpress网站上获得502错误后,我做了一些谷歌搜索,发现我需要更改我的Nginx配置,以匹配PHP脚本到PHP5-fpm.sock而不是端口9000的传递.所以我将我的网站的配置文件更改为以下:
# Pass PHP scripts on to PHP-FPM
location ~* \.PHP${
try_files $uri /index.PHP;
fastcgi_index index.PHP;
fastcgi_pass unix:/var/run/PHP5-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
检查错误日志后,我得到:
2014/03/30 14:16:37 [error] 1451#0: *21 connect() Failed (111: Connection refused) while connecting to upstream,client: 81.107.86.251,server: www.harryg.me,request: "GET / HTTP/1.1",upstream: "fastcgi://127.0.0.1:9000",host: "harryg.me"
所以看起来像PHP-fpm试图将东西传递给fastcgi://127.0.0.1:9000.为什么不遵守配置文件的变化?
编辑:
我的/etc/PHP5/fpm/pool.d/www.conf里面有listen = /var/run/PHP5-fpm.sock.
最佳答案
我也有这个问题,我通过使用TCP连接解决了这个问题.引用此答案Error 502 in nginx + php5-fpm(在danmash的链接后面找到):
原文链接:https://www.f2er.com/nginx/435439.htmlThe issue is socket itself,its problems on high-load cases is well-known. Please consider using TCP\IP connection instead of unix socket,for that you need to make these changes:
在你的情况下,它将是127.0.0.1:9000.