Nginx PHP FASTCGI失败 – 如何调试?

前端之家收集整理的这篇文章主要介绍了Nginx PHP FASTCGI失败 – 如何调试?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我在AMAZON EC2上运行Nginx PHP的服务器,通过端口9000运行PHP FASTCGI.

服务器运行良好几分钟,过了一会儿(在这种情况下几千次点击)FastCGI Dies和Nginx返回502错误.

Nginx日志显示

 2010/01/12 16:49:24 [error] 1093#0: *9965 connect() Failed (111: Connection refused) while connecting to upstream,client: 79.180.27.241,server: localhost,request: "GET /data.PHP?data=7781 HTTP/1.1",upstream: "fastcgi://127.0.0.1:9000",host: "site1.mysite.com",referrer: "http://www.othersite.com/subc.asp?t=10"

如何调试导致FastCGI死亡的原因?

最佳答案
我意识到OP现在可能已经开始了,但是如果有人带着同样的问题来到这里,我希望这会有所帮助.

在默认设置中,Nginx用户“nobody”运行,而spawn-fcgi以用户“root”生成php-cgi子.因此,Nginx无法使用当前权限连接到fastcgi://127.0.0.1:9000.您所要做的就是更改spawn-fcgi命令以解决此问题.

spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi -C 5 -U nobody

或者您可以使用UNIX套接字(我更喜欢这种方法)

spawn-fcgi -s /var/run/fcgi.sock -f /usr/bin/php-cgi -C 5 -U nobody

并将Nginx.conf中的fastcgi_pass更改为:

...
 location ~ \.PHP${
        fastcgi_pass   unix:/var/run/fcgi.sock;
        fastcgi_index  index.PHP;
        include        fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /usr/local/Nginx/html$fastcgi_script_$
    }
...
原文链接:https://www.f2er.com/nginx/435144.html

猜你在找的Nginx相关文章