我在共享主机上,有cPanel, Apache, PHP是由FastCGI运行的。PHP在哪里存储错误日志?

是否有其他方法可以在共享主机环境中找到错误日志,而不必通过整个站点结构来查找error_log文件?

我可以访问PHP .ini文件(我使用PHP 5.2.16版本)。


当前回答

如果你使用php5-fpm默认日志,它应该在下面:

/var/log/php5-fpm.log

其他回答

Linux

php --info | grep error 

终端将输出错误日志位置。

窗户

php --info | findstr /r /c:"error_log"

命令提示符将输出错误日志位置。

命令,设置日志的位置

打开php.ini并添加以下行:

error_log = /log/myCustomLog.log

感谢chelmertz和Boom对这个问题的评论。

如何找到你的PHP错误日志在Linux:

sudo updatedb

[sudo] password for eric:

sudo locate error_log

/var/log/httpd/error_log

另一种等效的方法:

sudo find / -name "error_log" 2>/dev/null

/var/log/httpd/error_log

如果您从源代码构建Apache和PHP,那么错误日志默认生成在${Apache安装目录}/logs/error_log,即通常为/usr/local/apache2/logs/error_log。

否则,如果您已经从存储库中安装了它,则会在/var/log/apache2/error_log中找到它。

你也可以在php.ini中设置路径,并通过调用phpinfo()来验证它。

在php.ini中配置错误日志文件时,可以使用绝对路径或相对路径。相对路径将基于生成脚本的位置进行解析,并且您将在拥有脚本的每个目录中获得一个日志文件。如果希望所有错误消息都保存在同一个文件中,请使用该文件的绝对路径。

请参阅错误处理函数。

cPanel错误日志位于:

/ usr / local / cpanel / logs / / usr / local / apache / logs /

默认情况下,Apache日志位于:

/var/log/apache

or

/var/log/apache2

如果有人正在使用自定义日志位置,那么你可以通过运行这个命令来检查它:

cat /etc/apache2/**conf**/httpd.conf | grep ErrorLog

如果你得到一个apache2目录不存在的错误,你可以运行这个命令来找到正确的位置:

whereis apache

or

whereis apache2