天天看點

nginx+php測試時顯示 502 bad gateway的解決方法

我測試nginx解析PHP時,報502網關錯誤:如下圖

<a href="http://s5.51cto.com/wyfs02/M00/82/EB/wKiom1dk--qSD_fsAAAxgrmIqTI431.png" target="_blank"></a>

檢視錯誤日志:

<a href="http://s1.51cto.com/wyfs02/M01/82/EA/wKioL1dk--yQCi9uAAReKgauz3E914.png" target="_blank"></a>

特别是:connect() to unix:/tmp/php-fcgi.sock failed (13: Permission denied) while connecting to upstream出錯,

然後我檢查我的nginx的sock檔案的權限:

# ll /tmp

total 4

srwxrwxrwx 1 mysql mysql    0 Feb 22 00:58 mysql.sock

drwxr-xr-x 3 root  root  4096 Feb 16 13:59 pear

srw-rw---- 1 root  root     0 Feb 22 00:58 php-fcgi.sock

修改後的權限

[root@centos3 nginx]# chmod 777 /tmp/php-fcgi.sock

[root@centos3 nginx]# ll /tmp

srwxrwxrwx 1 root  root     0 Feb 22 00:58 php-fcgi.sock

顯示的結果:

# curl localhost/2.php

This is a test

[root@centos3 nginx]#

這時nginx的502錯誤已解決了;

本文轉自 linuxpp 51CTO部落格,原文連結:http://blog.51cto.com/1439337369/1790616,如需轉載請自行聯系原作者

繼續閱讀