I'm using NGINX to serve PHP requests. My setup is essentially the same as what is described at http://wiki.nginx.org/PHPFastCGIOnWindows (less the RunHiddenConsole.exe wrapper bit).

Everything functions as expected the vast majority of the time. However, on occasion, NGINX will hang, and whenever it does, I know immediately the cause: php-cgi.exe exited.

If I go to look for the cmd.exe console window in which php-cgi.exe was running, it is gone. So, it's obvious that php-cgi.exe is exiting.

What might be the cause for this unexpected termination? This behavior most often occurs when I'm viewing MySQL tables with a large number of columns via phpMyAdmin, so it's possible that highly-concurrent requests are a factor. Although, I am the only person making requests to this NGINX server; it's running in an isolated environment on localhost. It's not as though this is some production server under a heavy load.

Has anyone else observed this behavior? Where might I start the debugging process? Nothing is logged to PHP's error log when this occurs.

Thanks for any pointers.

ETA:

Immediately after I posted this, I recalled an issue that I experience some years ago in which PHP (via FastCGI) would exit and reload after every 500 requests serviced. A quick search for the relevant terms lead me to http://stackoverflow.com/questions/12487147/php-cgi-exe-quits-after-exactly-500-hits . Could this be my problem? I'll try the solution as suggested and see if the problem disappears. (I'll report my findings here, of course.)

    23 days later

    That was it! I just had to add "SET PHP_FCGI_MAX_REQUESTS=0" to the script that starts php-cgi.exe:

    @ECHO OFF
    ECHO Starting PHP FastCGI...
    SET PHP_FCGI_MAX_REQUESTS=0
    SET PATH="D:\Program Files\php;%PATH%"
    "C:\Program Files\php\php-cgi.exe" -b 127.0.0.1:9000 -c "C:\Program Files\php\php.ini"
    
      Write a Reply...