PHP via FastCGI: “terminated by calling exit()”

apache-2.2fastcgilog-filesPHP

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.

Best Answer

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.