php-cgi.exe quits after exactly 500 hits

I finally figured it out. Maybe it was simple enough that I couldn't find the solution.

Adding:

SET PHP_FCGI_MAX_REQUESTS=0 

to the command file that launches the php-cgi.exe fixed it. I guess it defaults (when not set) to 500 hits before FCGI is killed.

Obviously, there are good reasons for this and as GargantuChet has suggested, settings things up correctly and letting the instances of PHP managed and auto-spawn is a better way to go...but for people who want a quick windows development environment, this can solve some problems.


The selected answer works, but doesn't allow the CGI server to shut down every so often (after 500 hits in the OPs case).

Like the OP and others mentioned, this shutdown is necessary in a production environment to curtail memory leaks.

In Windows, another solution is to create a batch file that looks like this:

:start
    php-cgi -b 127.0.0.1:9000
    goto start

This will allow the shutdown that was designed to occur, and will almost immediately start php-cgi again.

Tags:

Windows

Nginx

Php