简体   繁体   English

如何在Ubuntu Apache中启用错误日志

[英]How to enable error log in Ubuntu Apache

How can I enable error log on my Ubuntu Apache Server so that if any error occurs be it any PHP Syntax and other errors, server error should get stored in error log file 如何在我的Ubuntu Apache服务器上启用错误日志,以便在发生任何错误时发生任何PHP语法和其他错误,服务器错误应该存储在错误日志文件中

Also how can I view apache error log file? 另外我如何查看apache错误日志文件?

By default, /var/log/apache2/error.log . 默认情况下为/var/log/apache2/error.log

This can be configured in /etc/php5/apache2/php.ini 这可以在/etc/php5/apache2/php.ini配置

You can also define a specific error log file for each VirtualHost in Apache. 您还可以为Apache中的每个VirtualHost定义特定的错误日志文件。 If you have any VirtualHost defined in /etc/apache2/sites-available/ and enabled in /etc/apache2/sites-enabled (enable with sudo a2ensite [your-virtualhost-definition-file] ), you can change the error log by adding the following line inside your VirtualHost config: 如果在/etc/apache2/sites-available/定义了任何VirtualHost并在/etc/apache2/sites-enabled (使用sudo a2ensite [your-virtualhost-definition-file]启用),则可以通过以下方式更改错误日志:在VirtualHost配置中添加以下行:

ErrorLog ${APACHE_LOG_DIR}/[your-vhost]-error.log

That might be useful if you have a lot of vhosts and want to split where they report the errors. 如果你有很多虚拟主机并且希望在报告错误的地方进行拆分,那么这可能很有用。

Also, you can watch your error log live by issuing the following command (adapt to your own log file if different from the default): 此外,您可以通过发出以下命令来实时查看错误日志(如果与默认文件不同,则适应您自己的日志文件):

sudo tail -f /var/log/apache2/error.log

For more information check out the following links 有关更多信息,请查看以下链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM