502 Bad Gateway
nginx/1.2.9
在百度上查找錯誤信息:nginx+PHP 錯誤502 bad gateway時,也沒有找到好的方法,這時我分析我的nginx日志文件,我的nginx日志文件存放在/usr/local/nginx/logs/nginx_error.log,發(fā)現(xiàn)有如下一行的錯誤:2016/02/22 15:12:26 [crit] 2967#0: *9 connect() to unix:/tmp/php-fcgi.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /2.php HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-fcgi.sock:", host: "localhost"特別是:connect() to unix:/tmp/php-fcgi.sock failed (13: Permission denied) while connecting to upstream出錯,然后我檢查我的nginx的sock文件的權(quán)限:
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
修改后的權(quán)限
[root@centos3 nginx]# chmod 777 /tmp/php-fcgi.sock
[root@centos3 nginx]# 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
srwxrwxrwx 1 root root 0 Feb 22 00:58 php-fcgi.sock
顯示的結(jié)果:
curl localhost/2.php
This is a test
[root@centos3 nginx]#
這時nginx的502錯誤已解決了;
更多PHP相關(guān)技術(shù)請搜索千鋒PHP,做真實的自己,用良心做教育。
互聯(lián)網(wǎng)+時代,時刻要保持學習,攜手千鋒PHP,Dream It Possible。