https://stackoverflow.com/questions/17824462/internal-server-error-500-after-90-seconds-of-php-script-running/18729592
The solution is to increase the FastCGI activity timeout.
Use appcmd, the IIS command line tool, to modify the IIS configuration XML file.
Run cmd in an administrator mode.
To check the current settings use:
%windir%\system32\inetsrv\appcmd list config -section:system.webServer/fastCgi
To add the activity timeout (assuming CGI location is C:\php\php-cgi.exe):
%windir%\system32\inetsrv\appcmd set config -section:system.webServer/fastCgi /[fullPath='C:\php\php-cgi.exe'].activityTimeout:600
This output now should be similar to this:
<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>