【问题标题】:Why do my php error_log() statements get sent to the apache error.log?为什么我的 php error_log() 语句会发送到 apache error.log?
【发布时间】:2011-06-21 12:46:20
【问题描述】:

我尝试过的:

php.ini

log_errors = On
error_log = /etc/httpd/logs/php_error.log 

httpd.conf

php_value error_log /etc/httpd/logs/php_error.log

我已经尝试了这些不同的组合,停止并启动了 httpd 并验证了这些设置在 phpinfo() 中被识别,但它仍然会进入 apache error.log 文件。

如何从 httpd error.log 文件的单独文件中获取 php error_log() 输出?

PHP 5.3.5
服务器版本:Apache/2.2.3

谢谢

【问题讨论】:

  • 奇怪,我尝试了这么多,但我也无法让它工作。 SELinux禁用,没有区别。 php.ini 中的完整或相对路径,没有区别。确保文件存在并且可由 apache 写入 - 没有区别。

标签: apache php


【解决方案1】:

...该文件应该可由网络服务器的用户写入...

来源:http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-log

尝试将日志目录更改为例如/var/log/php/my_php_errors.log 确保文件夹存在:

mkdir /var/log/php/

/etc/... 通常不用于记录,而是使用 /var/log/... 中的某些文件夹/文件

【讨论】:

  • Doh,该文件归 apache 所有,但父目录归 root 所有,其他用户没有读取权限。 /etc 路径只是到 /var/log/httpd 的软链接,这就是 CentOS 默认设置的方式。
【解决方案2】:

您使用两个不同的日志路径是否有原因?

error_log = /etc/httpd/logs/php_error.log
php_value error_log /etc/php/logs/php_error.log
                         ^^^^

/etc/php/logs 是否存在?

【讨论】:

    猜你喜欢
    • 2012-01-20
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-14
    相关资源
    最近更新 更多