我在 AMAZON EC2 上有一台服务器,通过端口 9000 运行带有 PHP FASTCGI 的 Nginx + PHP。
服务器运行了几分钟,一段时间后(在这种情况下有数千次点击)FastCGI 失效,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"
Run Code Online (Sandbox Code Playgroud)
如何调试导致 FastCGI 死亡的原因?
小智 5
我意识到 OP 现在可能已经开始了,但是如果有人带着同样的问题来到这里,我希望这会有所帮助。
在默认设置中,NGINX 以用户“nobody”的身份运行,而 spawn-fcgi 以用户“root”的身份生成 php-cgi children。因此,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
Run Code Online (Sandbox Code Playgroud)
或者您可以使用 UNIX 套接字(我更喜欢这种方法)
spawn-fcgi -s /var/run/fcgi.sock -f /usr/bin/php-cgi -C 5 -U nobody
Run Code Online (Sandbox Code Playgroud)
并将 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_$
}
...
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8519 次 |
最近记录: |