nidr 发表于 2018-12-16 12:27:27

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

  我测试nginx解析PHP时,报502网关错误:如下图
http://s5.运维网.com/wyfs02/M00/82/EB/wKiom1dk--qSD_fsAAAxgrmIqTI431.png
  查看错误日志:
http://s1.运维网.com/wyfs02/M01/82/EA/wKioL1dk--yQCi9uAAReKgauz3E914.png
特别是: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 rootroot4096 Feb 16 13:59 pear
srw-rw---- 1 rootroot   0 Feb 22 00:58 php-fcgi.sock
修改后的权限
# chmod 777 /tmp/php-fcgi.sock
# ll /tmp
total 4
srwxrwxrwx 1 mysql mysql    0 Feb 22 00:58 mysql.sock
drwxr-xr-x 3 rootroot4096 Feb 16 13:59 pear
srwxrwxrwx 1 rootroot   0 Feb 22 00:58 php-fcgi.sock
显示的结果:
# curl localhost/2.php
This is a test
#
  这时nginx的502错误已解决了;



页: [1]
查看完整版本: nginx+php测试时显示 502 bad gateway的解决方法