Jump to content

Apache webserver troubleshooting guide

Recommended Posts

This article provides troubleshooting steps for the Apache webserver .

Apache Webserver Status

If you have an issue with your site or webserver, firstly you should check your Apache status.

1) Debian/Ubuntu:
sudo systemctl status apache2

2) CentOS:
systemctl status httpd

If it isn’t, go ahead and restart Apache:

1) Debian/Ubuntu:
sudo service apache2 restart

2) CentOS:
sudo service httpd restart

Even if Apache is already operating, restarting the server might be helpful. This allows you to view the Apache starting message. If you receive an error, you can use the error text in an internet search to find further information.

Reload Apache Web Server

Reloading enables Apache to reread its configuration files and implement the changes without requiring a full restart, avoiding downtime for the web server. Run the following command to refresh Apache's configuration:

1) Debian/Ubuntu:

/etc/init.d/apache2 reload

2) CentOS:
/etc/init.d/httpd reload

Apache Logs

To check for Apache errors, you can try to use the tail command with the -f flag, which shows you the most recent part of the log live as it’s updated. For instance:

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

1) Debian/Ubuntu:

cat /var/log/apache2/error.log

2) CentOS:

cat /var/log/httpd/error_log

The access logs can also help you find specific information about visitors to your server. The default access log locations are:

1) Debian/Ubuntu:


2) CentOS:


Apache Configuration Syntax

Apache includes a syntax checking tool. You can use it to make sure you aren’t missing any brackets in your configuration files (and similar problems):

1) Debian/Ubuntu:

apache2ctl -t

2) CentOS:

httpd -t

Virtual Host Definitions Of Apache Webserver

There is another Apache tool that lets you see all the virtual hosts on the server, their options, and the file names and line numbers of where they are defined.

It helps to identify all the domains that are configured on the server. Further, it helps to locate the correct file of the domain where the configuration details should be updated.

1) Debian/Ubuntu:

apache2ctl -S

2) CentOS:

httpd -S

Explanation of the received output:

All your directives use IP addresses and port numbers that match the ones defined in the NameVirtualHost directives.

For example, if you have set NameVirtualHosts *:80, then the virtual host configuration should begin with:


Conflicting Directives Of Apache

If you make changes to a configuration option but don't see them take effect after reloading the server configuration, it's conceivable that a conflicting directive has overruled the new option. The most important thing to understand is that newer commands take precedence over previous ones that clash. As a result, the directive that has been read the most recently will always take effect.

Here are some points on how the directories are read:

  • Included files are read at the point of their inclusion before the rest of the original file is read.
  • When an entire directory is included, the files from that directory are included alphabetically based on the name.
  • Debian and Ubuntu operating systems have a file called /etc/apache2/ports.conf, where the NameVirtualHost and Listen directives are set. These values determine the IP address or addresses to which Apache binds, and on which port(s) the web server listens for HTTP requests. Sometimes it can conflict with the settings in other files.
  • Directory settings are read whenever the server starts or is reloaded. However, .htaccess files are read before resources are served. Due to this, .htaccess files can override directory configurations. So, for the testing, you should temporarily disable .htaccess files.

If you still have an issue with troubleshooting your Apache web server, then it might take a deeper investigation of your VPS. So you might need to consult with VPS administrator.
Also, for more information about Apache webserver, you can find here.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...