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 php5 behind a nginx proxy, as Fast_CGI, after some usage (Always while being used, not while idle. The Fast_CGI server just shuts down (no longer displays in a 'ps -A'.

In php.ini Log_Errors is set to On and Error_Log is set to /var/log/php.log, however if view php.log only the startup errors are displayed, nothing that would signify php shutting down.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The best way to find out what the problem is when you don't get any output is to run php under strace. Start up php and get the list of pids from ps. Then run:

# strace -f -o /tmp/php.strace.log -p pid1 -p pid2 -p pid3 ....
Once PHP dies, look in the log to see what happens. Having said that, in your particular instance, I suspect you have your environment variables wrong. If you have a single php process, this would agree with my hunch. PHP has an option to terminate after a certain number of requests. This is a sensible thing to do to prevent memory leaks and other such problems. There is also an option to specify the number of processes that are running at the same time. If there is only one process, after a number of requests, it will die. The solution is to run more than one processes. The options that I use are:
export PHP_FCGI_CHILDREN=4
export PHP_FCGI_MAX_REQUESTS=1000

If you put these lines in the script you use to start your php server, you should find your PHP website remains running. :)

share|improve this answer
    
Yeah, I only have one php process, I've just added that to my startup script and now I have 5 as expected.... Why is it that only one process will die after X requests, but there is no limit with more processes? –  Arelius Jun 7 '09 at 23:10
    
Because there's still other processes available to fork to make the right number. I'd have to say this is a bug in PHP. In theory, there should be a controlling process and $PHP_FCGI_CHILDREN number of processes serving requests. It would appear that this isn't the case. –  David Pashley Jun 7 '09 at 23:19

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.