PHP 通过 FastCGI:“通过调用 exit() 终止”

PHP 通过 FastCGI:“通过调用 exit() 终止”

我最近将我的服务器从 mod_php 设置转换为通过 mod_fcgid 设置的 php。一切都运行良好:速度快、简单、不会崩溃等等等等。

我遇到的问题是日志文件中充满了如下消息:

[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

如果我的 apache2.conf 文件已将日志记录设置为E_ALL & ~E_NOTICE。我的 php.ini 文件设置为不记录错误。

我确实exit在 php 代码中使用了该命令,但我不明白为什么它会在日志文件中发出通知。任何意见都将不胜感激。

答案1

在标准 CGI 脚本中,服务器启动脚本,向其发送单个请求,然后等待脚本终止。

在 FCGI 脚本中,服务器启动一次,然后一次发送多个请求。这意味着您的脚本不应该在单个请求后退出,而应该仅在无法做出有用响应的错误情况下退出(即使它使用 500 代码进行响应)。

因此,我相信,您的退出会让 Apache 感到困惑。

相关内容