原创河北强商网络科技有限公司 最后发布于2020-02-22 19:30:55 阅读数 40 收藏
展开
php错误日志与apache配置自身的错误日志ErrorLog的区别
apache配置错误日志语法:
ServerRoot: The top of the directory tree under which the server’s
configuration, error, and log files are kept.
Do not add a slash at the end of the directory path. If you point
ServerRoot at a non-local disk, be sure to specify a local disk on the
Mutex directive, if file-based mutexes are used. If you wish to share the
same ServerRoot for multiple httpd daemons, you will need to change at
least PidFile.
ServerRoot “/etc/httpd”
ErrorLog: The location of the error log file.
If you do not specify an ErrorLog directive within a
container, error messages relating to that virtual host will be
logged here. If you do define an error logfile for a
container, that host’s errors will be logged there and not here.
ErrorLog “logs/error_log”
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
分析:
在mod_php的SAPI接口场景下:
只有在mod_php的SAPI接口场景且php.ini的error_log参数没有被配置的情况(包括error_log配置了但为空的情况),php的报错信息才会记录到apache的ErrorLog配置所记录的错误日志中,在mod_php模式下,该mod_php模块被集成到apache内部,因此mod_php作为apache的一个组成部分出现,因此apache能对php实现更多更精准的控制。(此种情况下,该httpd.conf中的错误日志配置的ErrorLog路径文件,将同时记录apache的web运行的错误日志(如httpd服务重启等,会被记录)和php执行的错误日志)。
cgi/fcgi的SAPI(如php-fpm)接口场景:
如果是cgi/fcgi的SAPI(如php-fpm)且php.ini的error_log参数没有被配置的情况(包括error_log配置了但为空的情况,如果用php-fpm,那么php-fpm的对error_log的配置也应该是没有配置或者配置了为空),php的报错信息才会记录到apache的ErrorLog配置所记录的错误日志中。(此种情况下,该httpd.conf中的错误日志配置的ErrorLog路径文件,将同时记录apache的web运行的错误日志(如httpd服务重启等,会被记录)和php执行的错误日志),(如果php-fpm与php.ini都配置了error_log,当通过php-fpm作为SAPI执行php的时候,php-fpm的配置将重写php.ini中的配置.)
综述:
只要php的运行时状态时,error_log的值不是not value,即存在有效路径值(可以通过php.ini,php-fpm配置,ini_set,apache的php_value等多种方法设置),那么php的错误日志就会被记录到该错误日志路径中。否则错误日志将记录到lamp架构中的httpd.conf中的ErrorLog配置文件中。
————————————————
版权声明:本文为CSDN博主「河北强商网络科技有限公司」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/yaqiang2017/article/details/104448909