【发布时间】:2013-04-13 08:23:32
【问题描述】:
使用 nginx 1.7 和 PHP(Laravel 框架)从 PostgreSQL 数据库中检索 1+ 百万行导致错误 500 在 10 秒内显示。
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
我已经将一些超时设置为更长并重新加载了 nginx,但它无法正常工作。哪些设置可以防止这种超时?
启用网站
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 6000;
fastcgi_send_timeout 6000;
client_body_timeout 6000;
send_timeout 6000;
proxy_read_timeout 6000;
}
【问题讨论】:
-
你确定超时在
nginx,而不是在PostgreSQL或FastCGI? NginX 应该给你一个 504 错误,而不是 500 错误。尝试在没有 NginX 的情况下加载相同的页面,看看会发生什么。不过,也请查看client_header_timeout指令,以防万一。 -
我可以使用 pgAdmin3 软件从 PostgreSQL 中检索所有 1M 行,因此 PostgreSQL 不是超时的。设置
client_header_timeout 6000,我仍然得到同样的错误500。我应该如何调整FastCGI超时? -
pgAdmin3 很可能会以不同于 Laravel 的方式处理这些行。你可以绕过
nginx访问 Laravel 页面吗?无论如何,请参阅下面的暂定答案以获取可能的线索和处理方式。
标签: php postgresql nginx laravel laravel-4