当我的PHP脚本运行时间超过平常时,我从nginx收到504超时消息. set_time_limit(0)似乎没有阻止这一点!在nginx上运行php5-fpm时它不起作用吗?如果是这样,那么设定时限的正确方法是什么?
错误:
504 Gateway Time-out
nginx/1.2.7
解决方法:
有几种方法可以设置php-fpm的超时.在/etc/php5/fpm/pool.d/www.conf中我添加了这一行:
request_terminate_timeout = 180
此外,在/ etc / nginx / sites-available / default中,我将以下行添加到相关服务器的位置块:
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秒的请求,不应再有超时.
标签:php,nginx,fastcgi
来源: https://codeday.me/bug/20190923/1814631.html