当我的PHP脚本运行时间比平时长时,我从nginx收到504超时消息。set_time_limit(0)
似乎不能阻止这一点!在nginx上运行php5-fpm不工作吗?如果是这样,设定时限的正确方式是什么?
错误:
504 Gateway Time-out
nginx/1.2.7
发布于 2013-07-07 18:48:31
有几种方法可以设置php-fpm的超时。在/etc/php5/fpm/pool.d/www.conf
中,我添加了下面这一行:
request_terminate_timeout = 180
另外,在/etc/nginx/sites-available/default
中,我将以下行添加到有问题的服务器的location块中:
fastcgi_read_timeout 180;
整个位置块如下所示:
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 180;
include fastcgi_params;
}
现在只需重新启动php-fpm和nginx,应该不会再有超过180秒的请求超时。
发布于 2013-10-11 01:41:50
试试这个link,它有一个更好的解决方案来解决这个问题。因此,步骤如下:
/etc/nginx
目录中的nginx.conf
文件。http {
部分下:client_header_timeout 3000;client_body_timeout 3000;fastcgi_read_timeout 3000;client_max_body_size 32m;fastcgi_buffers 8 128k;fastcgi_buffer_size 128k;
注意:如果已经存在,请更改according.
$ service nginx reload $ service php5-fpm reload
如果错误仍然存在,请考虑增加值。
发布于 2013-04-15 01:51:32
您不能使用PHP来阻止nginx发出的超时。
要将nginx配置为允许更多时间,请参阅proxy_read_timeout
directive。
https://stackoverflow.com/questions/16002268
复制相似问题