2

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.

mattbasta
  • 641
  • 1
  • 8
  • 17

1 Answers1

1

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.

Michael Graff
  • 6,668
  • 1
  • 24
  • 36
  • 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 03: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
  • 3
    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: http://www.fastcgi.com/drupal/node/6?q=node/15 – Roman Dec 02 '12 at 18:14