nginx – 将php更新为5.5后得到502坏网关

在我的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;
    }

然后我做了服务nginx重启.但502错误仍然存​​在.

检查错误日志后,我得到:

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的链接后面找到):

The 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:

  • in php-fpm pool configuration replace listen = /var/run/php5-fpm.sock with listen = 127.0.0.1:7777
  • in /etc/nginx/php_location replace fastcgi_pass unix:/var/run/php5-fpm.sock; with fastcgi_pass 127.0.0.1:7777;

在你的情况下,它将是127.0.0.1:9000.

转载注明原文:nginx – 将php更新为5.5后得到502坏网关 - 代码日志