PHP 脚本在 IIS 8.5 上无法运行超过 1 分钟

PHP 脚本在 IIS 8.5 上无法运行超过 1 分钟

我已将 max_execution_time 设置为 0,将 memory_limit 设置为 '-1',并将 FastCGI 的时间限制设置为 15 分钟,但运行 PHP 脚本超过 1 分钟时会出现“500 - 内部服务器错误”。

有人知道为什么即使我特意将其设置为更长的时间,它也不能运行超过 1 分钟吗?

答案1

https://stackoverflow.com/questions/17824462/internal-server-error-500-after-90-seconds-of-php-script-running/18729592

解决方案是增加 FastCGI 活动超时。使用 IIS 命令行工具 appcmd 修改 IIS 配置 XML 文件。

以管理员模式运行cmd。

要检查当前设置,请使用:

%windir%\system32\inetsrv\appcmd list config -section:system.webServer/fastCgi

添加活动超时(假设 CGI 位置是 C:\php\php-cgi.exe):

%windir%\system32\inetsrv\appcmd set config -section:system.webServer/fastCgi /[fullPath='C:\php\php-cgi.exe'].activityTimeout:600

现在输出应该类似于以下内容:

<fastCgi>
<application fullPath="C:\PHP\php-cgi.exe" activityTimeout="600" instanceMaxRequests="10000">
<environmentVariables>
<environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" />
</environmentVariables>
</application>
</fastCgi>
</system.webServer>

相关内容