nginx 502 网关错误 [英] nginx 502 bad gateway
问题描述
在使用 spawn fcgi 生成 php5-cgi 时,我使用 nginx 得到了 502 Bad Gateway.
I get a 502 Bad Gateway with nginx when using spawn fcgi to spawn php5-cgi.
我使用 rc.local 中的以下行在服务器启动时使用它来跨越实例
I use this to span an instance on server start using the following line in rc.local
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid
大概我收到错误是因为 spawn-fcgi/php5-cgi 死了,没有任何东西在那里听来解析 php.
presumably I'm getting the error because the spawn-fcgi / php5-cgi dies and there is nothing listening there anymore to parse php.
我在任何地方都看不到日志中的任何内容,我没有想法(并且不熟悉使用 nginx 进行此设置)
I get nothing in the logs that I can see anywhere, I'm out of ideas (and new to this setup with nginx)
推荐答案
我执行了我的 localhost
并且页面显示了 502 bad gateway
消息.这对我有帮助:
I executed my localhost
and the page displayed the 502 bad gateway
message. This helped me:
- 编辑
/etc/php5/fpm/pool.d/www.conf
- 将
listen =/var/run/php5-fpm.sock
更改为listen = 127.0.0.1:9000
- 确保位置在 nginx 中正确设置.确认.
- 运行
sudo service php5-fpm restart
- Edit
/etc/php5/fpm/pool.d/www.conf
- Change
listen = /var/run/php5-fpm.sock
tolisten = 127.0.0.1:9000
- Ensure the location is set properly in nginx.conf.
- Run
sudo service php5-fpm restart
也许它会帮助你.
来源:http://wildlyinaccurate.com/solving-502-bad-gateway-with-nginx-php-fpm
这篇关于nginx 502 网关错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!