我在共享主机上,有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.ini中配置错误日志文件时,可以使用绝对路径或相对路径。相对路径将基于生成脚本的位置进行解析,并且您将在拥有脚本的每个目录中获得一个日志文件。如果希望所有错误消息都保存在同一个文件中,请使用该文件的绝对路径。
请参阅错误处理函数。
其他回答
如何找到你的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
你可以在下面看到一个帐户的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
无论你想要它在哪里,如果你在函数调用中设置它:
error_log($errorMessageforLog . "\n", 4, 'somePath/SomeFileName.som');
您处于共享环境中,无法找到错误日志。总是检查你的cPanel仪表板是否有错误选项。如果您无法找到错误日志,那么您可以在那里找到它。
在cPanel搜索栏中,搜索Error,它将显示Error Pages,这基本上是不同HTTP错误页面的列表,其他Error是错误日志显示的地方。
共享环境中的其他地方:
/ home / yourusername / logs / home / yourusername / public_html error_log
如果你使用php5-fpm默认日志,它应该在下面:
/var/log/php5-fpm.log