php在執行中常見錯誤: The FastCGI process exceeded configured request timeout; FastCGI process exceeded configured activity timeout ;
一、iis下
iis下fastcgi模式執行php腳本。
首先需要設置fastcgi的最大執行時間,在此基礎上設置php腳本時間才會有效。即,假設fastcgi最大活動時間設為900s,則php用set_time_limit(max)函數,max在[0,900]有效,大於900則fastcgi斷開。
iis下fastcgi執行時間設置方法:
在“C:/WINDOWS/system32/inetsrv/fcgiext.ini”最末php的配置內容下增加一些參數,如下: 引用 [Types] php=PHP [PHP] ExePath=C:/PHP/php-cgi.exe InstanceMaxRequests=10000 EnvironmentVars=PHP_FCGI_MAX_REQUESTS:10000 RequestTimeout=500 ActivityTimeout=900
注:我服務器默認為90s
php腳本設置最大執行時間的方法:
1.、在php.ini里面設置 max_execution_time = 45; 2、通過PHP的ini_set 函數設置 ini_set("max_execution_time", "45"); 3、通過set_time_limit 函數設置 set_time_limit(45); 以上幾個數字設置為0 則無限制,默認一般是30秒。偶爾有特殊情況,可以在腳本里面使用函數修改
二、nginx下
nano /etc/php.ini max_execution_time = 900 ... nano/etc/fpm.d/www.conf request_terminate_timeout = 900 nano /etc/nginx/nginx.conf http { fastcgi_read_timeout 900; } ... 最后重啟服務: service php-fpm reload service nginx reload