Nginx+php7 502 Bad Gateway

2025-09-24 06:02:11

1、首先查找php-fpm位置:

1.find / -name php-fpm;

2.查看listen值;

Nginx+php7 502 Bad Gateway

2、打开nginx配置文件,查看fastcgi_pass配置项值;

fastcgi_pass   127.0.0.1:9000;

Nginx+php7 502 Bad Gateway

3、使用grep查看 php-fpm是否运行;

1.netstat -ant | grep 9000

2.结果为空,说明php-fpm未运行;

 

 

Nginx+php7 502 Bad Gateway

4、因此,将nginx配置文件中fastcgi_pass配置项改为 unix:/tmp/php-cgi.sock;

fastcgi_pass unix:/tmp/php-cgi.sock;

Nginx+php7 502 Bad Gateway

5、保存,并重启nginx;

/usr/local/nginx/sbin/nginx -s reload

Nginx+php7 502 Bad Gateway

6、再次访问,运行成功!!

Nginx+php7 502 Bad Gateway

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢