How to check Apache Error Logs on Linux Cloud Servers

2020-07-15 By Aaron 14483 Views linux apache troubleshooting
41 reviews

There may arise situations when a website hosted in a Linux server does not work properly and shows up error messages. The website showing error can be attributed to several factors, some of which may include incorrect permissions for files/folders, issues with the services serving the website, missing files, corrupted files/database, etc.

In a Linux server having Apache as the webserver, the error logs of the Apache service helps considerably in troubleshooting such issues with the websites. Checking the error logs in real-time can often assist in analyzing and finding the cause of what went wrong with the website and thereby the way to fix it.


This guide outlines the basic steps to find out, wherein the server, the Apache error log can be located as well as the way in which the error log can be monitored in real-time.


Location of Apache Error Log

Apache error log, by default, can be found in the locations specified below, based on the Linux OS distribution in the server.

  • CentOS/Fedora: /var/log/httpd/error_log
  • Ubuntu/Debian: /var/log/apache2/error.log


To find the exact location of the Apache error log, the below grep commands can be used:


CentOS / Fedora:

# grep ErrorLog /etc/httpd/conf/httpd.conf

apacheerror1


Ubuntu / Debian:

# grep ErrorLog /etc/apache2/apache2.conf

apacheerror2


Checking Apache error log in real time

Once the location of the Apache error log has been found out, it can be monitored in real-time for checking on finding the cause of any error that a website is facing.

For this, execute the below commands in the server, and then browse the website having the error in a web browser. The logs related to the errors of the website will automatically be shown in real-time.


CentOS/Fedora:

# tail -f /var/log/httpd/error_log


Ubuntu/Debian:

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


To search for any particular word in the Apache error log, the grep command can be used as below. In the below examples, the word permission is being searched in the error log.

# grep -i permission /var/log/httpd/error_log  (CentOS/Fedora)  

# grep -i permission /var/log/apache2/error.log  (Ubuntu/Debian)


Checking Apache error log in WHM/cPanel server

By default, the Apache error log in a WHM/cPanel server is located in the path /usr/local/apache/logs/error_log.


Any errors with websites hosted in the cPanel server will be logged in this error log and it can be monitored in real-time to find the cause of the error, by executing the below command.

# tail -f /usr/local/apache/logs/error_log


The error logs for a domain can also be checked from cPanel for the domain by clicking on the option named Errors under Metrics section.

apacheerror3


An example of an error message generated for a website in the Apache error log is shown below, the website name showing in the context of this guide is layerstacksupport.com, with the cPanel username being layerstacksuppor.

[Wed Jul 15 03:19:21.709170 2020] [proxy_fcgi:error] [pid 12023] [client 123.123.123.123:20810] AH01071: Got error 'Unable to open primary script: /home/layerstacksuppor/public_html/index.php (Permission denied)\n'

apacheerror4


This error means that permission to access the index page of the website is denied, which usually refers to incorrect permission for the index file. The necessary permissions can be updated for the index file to resolve this issue.

The same error log can also be viewed from the cPanel of the domain by navigating to Metrics >> Errors.

apacheerror5


Checking Apache error log in Plesk server

The location of the global Apache error logs in a Plesk server changes based on the type of Linux OS distribution in the server. The path of the error log is as provided below:


CentOS / RHEL: /var/log/httpd/error_log

Ubuntu / Debian: /var/log/apache2/error.log

Domain-specific error log: /var/www/vhosts/system//logs/error_log


Similar to cPanel server, the error log can be monitored in real time using the tail command as below:

# tail -f /var/www/vhosts/system/<domainname>/logs/error_log


The error logs for the domain can also be accessed from its Plesk panel, by clicking on the Logs option and then selecting the Apache error from the drop-down menu. Nginx error can also be selected if the server uses Nginx reverse proxy server.

apacheerror6

apacheerror7


An example of an error message generated for a website in the Apache error log is shown below, the website name showing in the context of this guide is layerstacksupport.com.

[Wed Jul 15 04:11:39.421314 2020] [proxy_fcgi:error] [pid 20878:tid 139906992543488] [client 123.123.123.123:55976] AH01071: Got error 'PHP message: PHP Fatal error:  Unknown: Failed opening required '/var/www/vhosts/layerstacksupport.com/httpdocs/index.php' (include_path='.:/opt/plesk/php/7.4/share/pear') in Unknown on line 0'

apacheerror8


This error means that the index page of the website failed to open, which usually refers to incorrect permission for the index file. The necessary permissions can be updated for the index file to resolve this issue.

The same error can also be viewed from the Plesk panel as below:

apacheerror9


Related Tutorials

What do you think about this article?

Rate this article
LayerStack Promotion
Need assistance?

Try this guide to receive free bundled services at signup on a new free account.

Sign Up

Your Feedback Is Important

We hope you’ll give the new products and updates a try. If you have an idea for improving our products or want to vote on other user ideas so they get prioritized, please submit your feedback on our Community platform. And if you have any questions, please feel free to ask in the Community or contact our Technical Support team.