我在共享主机上,有cPanel, Apache, PHP是由FastCGI运行的。PHP在哪里存储错误日志?
是否有其他方法可以在共享主机环境中找到错误日志,而不必通过整个站点结构来查找error_log文件?
我可以访问PHP .ini文件(我使用PHP 5.2.16版本)。
我在共享主机上,有cPanel, Apache, PHP是由FastCGI运行的。PHP在哪里存储错误日志?
是否有其他方法可以在共享主机环境中找到错误日志,而不必通过整个站点结构来查找error_log文件?
我可以访问PHP .ini文件(我使用PHP 5.2.16版本)。
当前回答
php --info | grep error
这很有帮助。
其他回答
在共享的cPanel环境中,如果你的主机提供商没有在cPanel仪表板中提供任何选项,你就无法找到错误日志。你可以搜索“错误”,看看你的提供商是否有任何错误。
否则,您通常会在public_html文件中找到一个名为“error_log”的文件,其中记录了所有PHP错误。
如果PHP是apache2模块,PHP将错误日志存储在/var/log/apache2中。 共享主机通常将日志文件存储在根目录/日志子文件夹中。 但是…如果你可以访问php.ini文件,你可以这样做:
error_log = /var/log/php-scripts.log
根据rinogo的评论:如果您正在使用cPanel,您可能正在寻找的主日志文件(默认情况下)存储在
/usr/local/apache/logs/error_log
如果所有这些都失败了,您可以使用
<?php phpinfo(); ?>
你可以在下面看到一个帐户的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
对于CentOS 8,它是var/log/httpd/error_log。
对于PHP-FPM,只需搜索配置文件error_log:
cat /etc/php-fpm.d/www.conf | grep error_log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log