This article provides troubleshooting guidelines for the Apache web server. Apache is a highly customizable tool for serving HTTP traffic. Because it allows for so many different configurations and settings in so many different places, sometimes Apache configuration can befuddle even advanced users.
In this guide, you’ll start with some basic troubleshooting steps and then proceed to more advanced techniques that can help you untangle conflicting directives. We recommend starting at the beginning of this guide and going through it in order. By the time you’re done, you should be able to debug your Apache installation.
First, check whether Apache is running.
If it isn’t, go ahead and restart Apache, as explained in the next section.
You may also want to investigate the possibility of memory issues, if Apache is stopping unexpectedly.
Even if Apache is running, it can be useful to restart the server. This will let you read the Apache startup message. If you get an error, you can use the text of the error in an online search to help you find more details and solutions. Restarting the server may produce several seconds of downtime.
Debian and Ubuntu:
sudo service apache2 restart
Fedora and CentOS:
sudo service httpd restart
Restarting or reloading Apache is also useful if you’ve recently made changes to your server, but they don’t seem to be taking effect. This is true for changes made directly in the Apache configuration files, as well as for changes you’ve made to the configuration for a dynamic language like mod_python, mod_rails (for example, Phusion Passenger, or mod_rack), mod_ruby, etc. These interfaces cache code internally, and do not reread scripts on new requests.
Reloading makes Apache reread its configuration files and incorporate the changes without a full restart, which avoids web server downtime. To reload Apache’s configuration, run the following command:
The best place to check for Apache errors is the Apache error logs. To view the error logs, we recommend using the tail command with the -f flag, which shows you the most recent part of the log live as it’s updated. Example:
tail -f /var/log/apache2/error.log
Type CTRL-C to exit the live log.
The default error log locations are:
The access logs can also help you find specific information about visitors to your server. The default access log locations are:
Sometimes it can be helpful to see extra information from Apache. You can increase the amount of detail shown in the logs by changing the log level.
sudo nano /etc/apache2/apache2.conf
2. Locate the LogLevel variable, and update it from the default warn to info or debug. debug will produce the greatest amount of output.
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
3. Restart Apache:
sudo service apache2 restart
4. Perform the operation that was giving you trouble, then check the logs for more detailed information and errors.
Caution: Remember to set the LogLevel back to warn when you’re done troubleshooting, or your server may fill up with logs.
Apache includes a nice little syntax checking tool. Use it to make sure you aren’t missing any brackets in your configuration files (and similar problems).
Another helpful Apache tool lets you see all the virtual hosts on the server, their options, and the file names and line numbers of where they are defined. This will help you inventory all the domains that are configured on your host. It will also help you locate the correct file where you should update the configuration details for a domain, if you’re not quite sure where you originally put them.
Make sure all your <VirtualHost> 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 <VirtualHost *:80>. If you’ve set NameVirtualHosts 184.108.40.206:80, then the virtual host configuration should begin with <VirtualHost 220.127.116.11:80>. If you’ve set NameVirtualHosts *, then the virtual host configuration should begin with <VirtualHost *>.
Note: You can have multiple NameVirtualHost values, which is what you’ll need to do if you’re running sites on multiple IPs and ports. Just make sure the <VirtualHost> configurations correspond to the configured NameVirtualHost directives.
Powered by BetterDocs