Apache不记录PHP错误 [英] Apache does not log php errors

查看:90
本文介绍了Apache不记录PHP错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过CLI的PHP成功将错误记录到/var/log/php_errors.log.

PHP via CLI successfully logs errors to /var/log/php_errors.log.

但是apache + php不会记录错误.

But apache + php does not log errors.

[bla@notebook ~]$ apachectl -v
Server version: Apache/2.2.17 (Unix)
Server built:   May 19 2011 03:15:39

[bla@notebook ~]$ php -v
PHP 5.3.6 with Suhosin-Patch (cli) (built: Mar 23 2011 13:28:00) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

php.ini 中,我有:

display_errors = On
error_reporting = E_ALL | E_STRICT
log_errors = On
error_log = php_errors.log

httpd.conf 中:

ErrorLog "/var/log/httpd/error_log"

权限:

[bla@notebook /]$ ls -la /var/log/httpd/
-rwxrwxr-x 1 root root 133351 21.11.2011 11:18 access_log*
-rwxrwxr-x 1 root http   1307 21.11.2011 11:18 error_log*

[bla@notebook /]$ ls -la /var/log/php_errors.log 
-rwxrwxr-x 1 root http 521 14.11.2011 17:31 /var/log/php_errors.log*

如您所见,Apache守护程序有权写入日志文件.

As you can see the Apache daemon has permissions to write into log files.

在/var/log/php_errors.log和/var/log/httpd/error_log中仍然没有来自Apache或PHP的错误.

Still no errors from Apache or PHP in /var/log/php_errors.log and /var/log/httpd/error_log.

更新1.

更改了php.ini中的这一行:

Changed this line in php.ini:

error_log = php_errors.log 

完整路径:

error_log = /var/log/php_errors.log 

权限还可以.但是,如果有人也遇到问题,则可以调试对日志文件0777的设置权限或更改文件所有者.

Permissions were ok. But if someone is also having problems with it, you can debug setting permissions to logfile 0777 or changing file owner.

推荐答案

通常有两个用于Apache和CLI的单独的php.ini文件-您确定要查找正确的文件吗?

There are usually two separate php.ini files for Apache and CLI - are you sure you're looking at the correct one?

另外2个选择:

  • 某些Apache指令弄乱了PHP的日志路径(或禁用了日志记录选项,尽管这种情况不太可能发生)-尝试在php.ini中设置日志文件的绝对路径(@Frosty Z提出了一些建议)这样)
  • 我注意到您的PHP安装已应用Suhosin补丁程序,该补丁程序进行了一些限制性修改以提高安全性.从理论上讲,http用户组中的用户有足够的权限写入日志文件-可能存在一些类似的行为,并且当您通过Web访问脚本时,脚本将使用/作为用户名执行.设置为所有者(脚本的文件所有者)-尝试对其进行更改.
  • some Apache directive is messing with PHP's log path (or disabling the logging options, though that is very unlikely to be the case) - try setting an absolute path to the log file in php.ini (@Frosty Z has suggested something like this)
  • I notice that your PHP installation has the Suhosin patch applied, which does several restrictive modifications in order to improve security. And while in theory there are sufficient permissions for a user in the http user group to write to the logfile - there's probably some suphp-like behaviour and when your script is accessed through the web it is executed with/as the username that is set as it's owner (file owner of the script that is) - try changing it.

这篇关于Apache不记录PHP错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆