我在共享主机上,有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似乎不会在任何地方记录错误。在我看到的所有安装中,php.ini中的error_log键都被注释掉了。
通常我:
寻找php.ini文件。找到php . ini。 在这些文件中搜索error_reporting值; 它应该被设置为PHP日志级别的任意组合。 例如:E_ALL & ~E_DEPRECATED & ~E_STRICT 检查error_log值,确保它指向一个实际的位置,没有被注释掉。 默认值没有给出完整的路径,只有一个文件名,我不知道这个路径通常解析到哪里。可能/var/log/.
其他回答
你可以在下面看到一个帐户的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
因为某种原因,我把它存储在:
/ var / log / php-errors日志。
我使用的是Ubuntu Server 16.04 (Xenial Xerus)和PHP 7.1.28。
在php.ini文件中设置error_log变量时应使用绝对路径,否则错误日志将根据相对路径存储。
error_log = /var/log/php.errors
其他解决方案是编写简单的脚本,从目录树中列出所有错误日志文件。
如果您从源代码构建Apache和PHP,那么错误日志默认生成在${Apache安装目录}/logs/error_log,即通常为/usr/local/apache2/logs/error_log。
否则,如果您已经从存储库中安装了它,则会在/var/log/apache2/error_log中找到它。
你也可以在php.ini中设置路径,并通过调用phpinfo()来验证它。
最好的方法是查看httpd.conf文件,看看默认值是什么。它也可以被特定的虚拟主机覆盖。我首先查看/etc/httpd/conf/httpd.conf或/etc/apache2/httpd.conf并搜索error_log。它可以被列出为/var/log/httpd/error_log或/var/log/apache2/error_log,但也可以简单地列出为logs/error_log。
在这种情况下,它是一个相对路径,这意味着它将在/etc/httpd/logs/error_log下。如果仍然找不到它,请检查httpd.conf文件的底部,并查看虚拟主机包含在哪里。它可能在/etc/httpd/conf中。D / <-作为“其他”或“额外”。你的虚拟主机可以用ErrorLog "/path/to/error_log"覆盖它。