Nginx是一款高性能,高并发的web服务器。常应用web开发当中。比如使用nginx+php的项目,运行时,提示502 bad gateway ,该如何处理呢?
工具/原料
1
nginx;
2
linux;
3
php;
方法/步骤
1
首先查找php-fpm位置:1.find / -name php-fpm;2.查看listen值;
2
打开nginx配置文件,查看fastcgi_pass配置项值;fastcgi_pass 127.0.0.1:9000;
3
使用grep查看 php-fpm是否运行;1.netstat -ant | grep 90002.结果为空,说明php-fpm未运行;
4
因此,将nginx配置文件中fastcgi_pass配置项改为 unix:/tmp/php-cgi.sock;fastcgi_pass unix:/tmp/php-cgi.sock;
5
保存,并重启nginx;/usr/local/nginx/sbin/nginx -s reload
6
再次访问,运行成功!!
注意事项
502 bad gateway的原因有多种,这是其中一的一种,仅供参考!