1

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

2 Answers 2

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.

2
  • 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) :| Commented May 31, 2011 at 5:09
  • @mrm8 Apparently you can have php-fpm on Debian Squeeze (6.x) using dotdeb.org. Commented May 12, 2012 at 17:04
0

multiwatch was designed for this (to restart child processes being run by spawn-fcgi) -- see http://cgit.stbuehler.de/gitosis/multiwatch/about/

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.