加入收藏 | 设为首页 | 会员中心 | 我要投稿 阜阳站长网 (https://www.0558zz.com/)- 科技、建站、内容创作、云计算、网络安全!
当前位置: 首页 > 运营中心 > Nginx > 正文

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

发布时间:2020-09-18 17:43:07 所属栏目:Nginx 来源:互联网
导读:在我的ubuntu 12.10服务器上,我将php升级到5.5.在我的wordpress网站上获得502错误后,我做了一些谷歌搜索,发现我需要更改我的nginx配置,以匹配php脚本到php5-fpm.sock而不是端口9000的传递.所以我将我的网站的配置文件更改为以下: # Pass PHP scripts on to P

在我的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 TCPIP 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.

(编辑:阜阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读