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

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

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


当前回答

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

/var/log/php5-fpm.log

其他回答

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

/var/log/php5-fpm.log

在命令行中输入cat <file location> | grep ErrorLog在httpd.conf文件中查找ErrorLog。例如:

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

输出:

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
ErrorLog "/private/var/log/apache2/error_log"

找到以ErrorLog开头的行,这就是答案。

注意:对于虚拟主机,您可以编辑虚拟主机文件httpd-vhosts.conf以指定不同的日志文件位置。

无论你想要它在哪里,如果你在函数调用中设置它:

error_log($errorMessageforLog . "\n", 4, 'somePath/SomeFileName.som');

在LAMP环境中,PHP错误默认指向下面这个文件。

/var/log/httpd/error_log

所有访问日志分为:

/var/log/httpd/access_log

NGINX通常将其存储在/var/log/nginx/error.log或access.log(在Ubuntu上)。