我在AMAZON EC2上运行Nginx PHP的服务器,通过端口9000运行PHP FASTCGI.
服务器运行良好几分钟,过了一会儿(在这种情况下几千次点击)FastCGI Dies和Nginx返回502错误.
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
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_$
}
...