nginx+php显示 502 bad gateway的解决方法

502 Bad Gateway

 

 


nginx/1.2.9

 

 


在百度上查找错误信息:nginx+PHP 错误502 bad gateway时,也没有找到好的方法,
这时我分析我的nginx日志文件,我的nginx日志文件存放在/usr/local/nginx/logs/nginx_error.log,发现有如下一行的错误:
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文件的权限:

# 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

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

显示的结果:

# curl localhost/2.php

This is a test

[root@centos3 nginx]#

这时nginx的502错误已解决了;

 

更多PHP相关技术请搜索千锋PHP,做真实的自己,用良心做教育。

互联网+时代,时刻要保持学习,携手千锋PHP,Dream It Possible。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值