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

前端之家收集整理的这篇文章主要介绍了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相关文章