我发现在连续请求几个 php 页面之后,页面加载时间似乎变慢了,最终无法加载,并出现 504。
除了 php5-fpm 日志中的这个错误之外,我找不到任何相关错误
[13-Dec-2013 17:53:41] WARNING: [pool web36] child 6797 exited on signal 9 (SIGKILL) after 3165.155870 seconds from start
[13-Dec-2013 17:53:41] NOTICE: [pool web36] child 8078 started
[13-Dec-2013 17:55:15] WARNING: [pool web36] child 7848 exited on signal 9 (SIGKILL) after 633.767987 seconds from start
[13-Dec-2013 17:55:15] NOTICE: [pool web36] child 8100 started
[13-Dec-2013 17:56:19] WARNING: [pool web36] child 7914 exited on signal 11 (SIGSEGV) after 455.341786 seconds from start
我从现在起该如何排除故障?
Ubuntu 12.04.1 LTS(GNU/Linux 3.2.0-31-generic x86_64)PHP 5.3.10-1ubuntu3.5 带有 Suhosin-Patch nginx/1.1.19
答案1
当您的 php 脚本花费的时间过长(超过 60 秒)时,Nginx 将抛出 504 网关超时。
可以优化php脚本或者增加nginxfastcgi_读取超时参数(http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html)。
例子:
location ~ /(index).php {
fastcgi_read_timeout 3m;
fastcgi_pass 127.0.0.1:8888;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}