If your Apache server is not loading a webpage at all or giving an error, you’ll have to troubleshoot it. As always, first, try restarting the service and rebooting the machine. If it still fails, use the steps below to find the cause of the issue.
How to Find the Error Log Path
Run these commands in order to diagnose and fix Apache configuration issues. It’s assumed you have root privileges if you don’t, add sudo
at the front. Instead of httpd
you may also use apachectl
which is a wrapper command around httpd
.
First, test if there are issues with the configuration.
httpd -t
If you see any issues there, fix them first.
If not, then check your server error and custom logs. You can use httpd to find your error log locations.
httpd -D DUMP_INCLUDES

Then for each of the config files, find where the log files are located.
cat /usr/local/etc/httpd/httpd.conf | grep -E "ErrorLog|CustomLog"

If the above fails, try to locate the file with the locate command.
locate error_log
Read the Last Log Messages
Note the log file paths mentioned in the result. (Ignore the commented lines with #
. Most of the errors will be written to error_log
or access_log
files. You can read the log, or use tail
command to read the last lines.
tail /usr/local/var/log/httpd/error_log
You can increase the output lines with -n
flag. For example, output last 50 lines.
tail -n 50 /usr/local/var/log/httpd/error_log
Other Possible Causes for Apache Server Restart Failures
Apache might sometimes leave a corrupt Process ID file, which might cause it to fail. If that happens, you may have to manually delete the file.
apachectl stop
rm /usr/local/var/run/httpd/httpd.pid
apachectl start
Or use all 3 commands in one line.
apachectl stop && rm /usr/local/var/run/httpd/httpd.pid && apachectl start
The pid file is genrally located in your httpd
folder. If it’s a custom path, it will be listed on your httpd.conf
file as a `PidFile variable.
Example (in httpd.conf)
PidFile /yourpathto/httpd.pid