iis下设置php最大执行时间

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 = 9
... nano/etc/fpm.d/www.conf
request_terminate_timeout = 9 nano /etc/nginx/nginx.conf
http {
fastcgi_read_timeout 9;
} ... 最后重启服务:
service php-fpm reload
service nginx reload
上一篇:PHP初学留神(四)


下一篇:用vld分析C++内存泄漏