I'm running nginx with php as fcgi. It's working just fine, however, php-cgi keeps on exit()ing after serving 500 requests. I tried increasing that value (PHP_FCGI_MAX_REQUESTS), and that worked, but that seems to be a workaround. Then I set it to 0, and it didn't exit() yet. But I think there's a reason why php-cgi should be restarted. At the moment, I'm running php-cgi with spawn-fcgi: when the php process exits, spawn-fcgi exits, too. Now, is there a way to automatically restart php (without dirty hacks like while [ 1 ]; do spawn-fcgi; done
etc)?
![](../../users/profiles/81496.webp)
- 65
- 2
- 4
2 Answers
Is there any reason you can't switch over to PHP-FPM? It comes with PHP >= 5.3, and there is a patch to enable it for 5.2. I've been using it for around a year now, and it's been perfectly stable with no issues. This would make your process spawning issue disappear, as PHP-FPM would transparently handle killing the old processes and restarting new ones for you.
The reason for PHP_FCGI_MAX_REQUESTS is that PHP will randomly stop responding to requests after a certain number of them. It seems that this bug may have been partially fixed in newer versions, but during my testing of 5.2.x I noticed it happened multiple times.
![](../../users/profiles/61431.webp)
- 5,572
- 1
- 25
- 31
-
Well, I'm using Debian stable (squeeze) - and php-fpm is only available on sid. Strange, http://php-fpm.org says that it's included in PHP core >= 5.3.3 (which Debian squeeze has got) :| – mrm8 May 31 '11 at 05:09
-
@mrm8 Apparently you can have php-fpm on Debian Squeeze (6.x) [using dotdeb.org](http://fak3r.com/2011/09/27/howto-install-php5-fpm-on-debian-squeeze/). – ash108 May 12 '12 at 17:04
multiwatch was designed for this (to restart child processes being run by spawn-fcgi) -- see http://cgit.stbuehler.de/gitosis/multiwatch/about/
![](../../users/profiles/22758.webp)
- 1,742
- 12
- 33