Had a couple of question this week around some issues that people were experiencing from long running PHP scripts that appear to timeout/hang and eventually stop/crash and is this problem with FastCGI or the application pool settings.
Let’s take a look at the FastCGI settings in the ApplicationHost.config
<fastCgi> <application fullPath="C:\PHP\php-cgi.exe" activityTimeout="60" instanceMaxRequests="10000"> <environmentVariables> <environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" /> <environmentVariable name="PHPRC" value="c:\php\" /> </environmentVariables> </application> </fastCgi>
You’ll the highlighted entries, the one that causes the PHP scripts to hang and stop running is activityTimeout – simply put this value defines for FastCGI to timeout when the cgi process doesn’t talk to IIS for that amount of time specified. So if you have a script that will run longer than this, make sure you adjust it appropriately. Of course, use this sensibly.
Couple other things highlighted are environment variables for PHP with FastCGI. PHP_FCGI_MAX_REQUESTS governs how many requests will be processed by PHP before the PHP recycling process happens. PHPRC tells PHP where the PHP runtime configuration (php.ini) configuration file is located for this fastcgi process.