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

I've recently converted my server from a mod_php setup to a php via mod_fcgid setup. Everything works well: it's fast, easy, doesn't crash, etc etc etc.

The problem that I'm having is that the log files are filling up with messages like this:

[Sat Nov 14 00:43:17 2009] [notice] mod_fcgid: process /var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper(9451) exit(server exited), terminated by calling exit(), return code: 0
[Sat Nov 14 00:43:23 2009] [notice] mod_fcgid: process /var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper(9453) exit(server exited), terminated by calling exit(), return code: 0
[Sat Nov 14 00:43:27 2009] [notice] mod_fcgid: process /var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper(9457) exit(server exited), terminated by calling exit(), return code: 0
[Sat Nov 14 00:43:27 2009] [notice] mod_fcgid: process /var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper(9459) exit(server exited), terminated by calling exit(), return code: 0
[Sat Nov 14 00:43:41 2009] [notice] mod_fcgid: process /var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper(9463) exit(server exited), terminated by calling exit(), return code: 0
[Sat Nov 14 00:43:47 2009] [notice] mod_fcgid: process /var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper(9461) exit(server exited), terminated by calling exit(), return code: 0
[Sat Nov 14 00:43:58 2009] [notice] mod_fcgid: process /var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper(9466) exit(server exited), terminated by calling exit(), return code: 0

If my apache2.conf file, I have logging set to E_ALL & ~E_NOTICE. My php.ini file is set not to log errors.

I do use the exit command in my php code, but I don't understand why it would throw a notice in the log files. Any input would be appreciated.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

In standard CGI scripts, the server starts up the script, sends it a single request, then expects the script to terminate.

In an FCGI script, the server starts it once, and sends many requests, one at a time. This means your script should not be exiting after a single request, but only exit in error conditions where it cannot answer usefully (even if it were to answer with a 500 code.)

So, you are confusing Apache by exiting at all, I believe.

share|improve this answer
    
Agreed, using exit in FastCGI is confused. –  BrianEss Nov 15 '09 at 23:39
    
I don't currently call exit() to terminate all scripts, I use it for input validation and when I'm outputting cached data, etc. Is there any way to simply terminate the script without throwing an error? Sometimes using exit() is simply unavoidable. –  mattbasta Nov 17 '09 at 3:04
    
In normal operation, you should never call exit(). If you find something you simply cannot cope with (like, a database connection failed, or the like) then you can of course. Otherwise, if you exit in the normal flow (and handling bad input is a normal flow on the web!) then you lose all the advantages of using fcgi at all. –  Michael Graff Nov 17 '09 at 11:26
    
This is wrong. In both CGI and FastCGI, a script is executed by a webserver to serve exactly one request, and then it terminates. The difference is that with CGI, a webserver creates a new process for each request, but with FastCGI, that process doesn't exit after each request is processed. Instead, it waits for more requests. There is a big difference between an OS process and a script execution! PHP's exit() is just to control logic of execution. It doesn't confuse Apache or any other webserver. For more details about FastCGI: fastcgi.com/drupal/node/6?q=node/15 –  Roman Dec 2 '12 at 18:14

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.