PHP开启error_log 错误日志

对于一些访问没有明显错误提示的PHP页面,我们可以通过error_log来做进一步的判定。但出于种种原因,有些服务器并没有开启PHP的error_log功能。可以暂时开启一下错误日志: 

编辑php.ini,将log_errors设置为on:

log_errors = On

然后重启apache即可。

如成功开启,就可以跟踪到对应的错误提示:

[Mon Sep 24 16:57:01 2012] [error] [client 218.5.80.210] PHP Warning:  fsockopen() has been disabled for security reasons in /home/bccgi-bin/fsockopen.php on line 2

[Mon Sep 24 16:57:02 2012] [error] [client 218.5.80.210] PHP Warning:  fsockopen() has been disabled for security reasons in /home/bccgi-bin/fsockopen.php on line 2

[Mon Sep 24 16:57:03 2012] [error] [client 218.5.80.210] PHP Warning:  fsockopen() has been disabled for security reasons in /home/bccgi-bin/fsockopen.php on line 2

[Mon Sep 24 16:57:04 2012] [error] [client 218.5.80.210] PHP Warning:  fsockopen() has been disabled for security reasons in /home/bccgi-bin/fsockopen.php on line

如果是Windows环境,除了将log_errors设置为on外,还需要定义error_log的路径及文件名:

error_log = d:/temp/error.log

(此目录需要授予php标识用户的修改权限,否则日志文件无法生成)

因为IIS没有error_log的概念,需要另外定义。

PHP 的详细介绍:请点这里
PHP 的下载地址:请点这里

相关推荐