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

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

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


当前回答

你可以在下面看到一个帐户的php错误:

/home/username/logs/domain_tld.php.error.log

可以在全局和本地设置php错误日志。

Globally through WHM: WHM -->> MultiPHP INI Editor --> "Editor Mode" Select the version of PHP you would like to set the error log Edit the parameter error_log. error_log = "/some/path" Change the filename to the desired error log file Save changes Locally though cPanel: CPanel -->> MultiPHP INI Editor --> "Editor Mode" Select the version of PHP you would like to set the error log Edit the parameter error_log. error_log = "/some/path" Change the filename to the desired error log file Home directory will set the option for all domains, addons, and subdomains configured on the account A specific domain will limit the change to that domain, or, in the case of an addon domain, the addon and the matching subdomain Save changes If PHP-fpm is enabled: WHM --> MultiPHP Manager Find the domain you'd like to change the error log location for Click "Edit PHP-FPM" Change the log location in "The error log file (error_log)" relative to the folder "logs" within the user's home directory Save changes

其他回答

尝试phpinfo()并检查“error_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以指定不同的日志文件位置。

php --info | grep error

这很有帮助。

因为某种原因,我把它存储在:

/ var / log / php-errors日志。

我使用的是Ubuntu Server 16.04 (Xenial Xerus)和PHP 7.1.28。

在php.ini文件中设置error_log变量时应使用绝对路径,否则错误日志将根据相对路径存储。

error_log = /var/log/php.errors

其他解决方案是编写简单的脚本,从目录树中列出所有错误日志文件。