Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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)?

share|improve this question

2 Answers 2

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.

share|improve this answer
    
Well, I'm using Debian stable (squeeze) - and php-fpm is only available on sid. Strange, php-fpm.org says that it's included in PHP core >= 5.3.3 (which Debian squeeze has got) :| –  mrm8 May 31 '11 at 5:09
    
@mrm8 Apparently you can have php-fpm on Debian Squeeze (6.x) using dotdeb.org. –  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/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.