frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

Apache webserver troubleshooting guide

IevazIevaz Administrator

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:

/var/log/apache2/access.log

2) CentOS:

/var/log/httpd/access_log

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.

Sign In or Register to comment.

Time4VPS

Learn how to install a web and database server, email, FTP client or other applications. Discover and share information on server security or optimization recommendations.
Feel free to join our constantly expanding community, participate in discussions, strengthen your knowledge on Linux and Windows server management!
© 2013 - 2024 Time4VPS. All rights reserved.

Get In Touch