Troubleshooting Apache

Reading the log files is the easiest way to troubleshoot Apache.


When troubleshooting Apache, the most straightforward approach is to read the log files. The logs usually consist of two files:

  • A log that records every request that reaches the web server, usually called the access log.

  • A log that records all errors that occur, typically called the error log.

This is what a configuration for a Virtual Host might look like:

Example virtual host configuration file
<VirtualHost *:80>
  ServerName glesys.se
  ServerAlias *.glesys.se
  DocumentRoot /var/www/glesys.se/htdocs/
  CustomLog /var/www/logs/glesys.com-access_log combined
  ErrorLog /var/www/logs/glesys.com-error_log
</VirtualHost>

The CustomLog directive specifies where the access log is located, and the ErrorLog directive indicates where the error log can be found.

A good troubleshooting approach is to start by checking the error_log.

For this, you can use tail -F from the shell on the Unix or Linux server, like so:

Command
tail -F /var/www/logs/glesys.com-error_log

tail is a command that lets you view the end of a log file. Using the -F option makes tail keep the file open continuously and display new lines as soon as they appear. There is probably already some information in the log file, and it might look like this:

[Wed Jul 18 20:59:09 2012] [error] [client 77.53.249.3] File does not exist: /var/www/glesys.se/htdocs/does-not-exist

In the example above, you can see that someone requested a page that doesn’t exist, with the name /does-not-exist.

Other types of errors can also appear, such as incorrect rewrite rules, permission issues, and so on.

Last updated

Was this helpful?