Troubleshooting: Apache Webserver Will Not Restart / Start

My CentOS Apache 2 (httpd) webserver will not start. It was working fine but I made few changes to httpd.conf and it is not restarting. What are some things to check in order to solve my issues?

If httpd / Apache will not restart, there are few things which you can check in order to get rid of problem. Ssh into your server and and try the following tips. Always, make a backup of existing working httpd.conf and other config files before making any changes to those files.

Check for config syntax error

Almost all web server including Apache supports config file syntax checking. To run syntax check for config files, enter:
# httpd -t
# httpd -S

Sample output:

Syntax OK

You should see “Syntax OK” message if config file httpd.conf is configured properly. Otherwise, it will display an error message on screen:

Syntax error on line 29 of /usr/local/etc/apache22/httpd.conf:
Invalid command 'ServerRoot1', perhaps misspelled or defined by a module not included in the server configuration

You can use vi to open file and correct syntax:
# vi +29 /usr/local/etc/apache22/httpd.conf

Check Apache error log file

Some time error is displayed on screen. However, checking the error log file will point out exact problem location:
tail -f /var/log/httpd-error.log
egrep -i 'warn|error' /var/log/httpd-error.log

DNS configuration

Like any other Internet serverm Apache requires working DNS client support via /etc/resolv.conf file. It is very particular about having it’s hostname be resolvable via DNS. Make sure dns is working and ServerName is set correctly in httpd.conf. ServerName directive gives the name and port that the server uses to identify itself. This can often be determined automatically, but we recommend you specify it explicitly to prevent problems during startup. If your host doesn’t have a registered DNS name, enter its IP address here.
Check your hostname from a shell prompt and set it as ServerName in httpd.conf file:
hostname -f

Check Apache / PHP / Python / CGI log file size

In most cases log files (including php and virtual domain logs) over 2GB will cause problem or error 500. So make sure that log files are under limit. If they are, then you can move or remove them out of log directories. Set up logrotate tool, which is designed to ease administration of systems that generate large numbers of log files. Use ls -lh command to list log file size:
# ls -lh /var/log/httpd*

Check for open file (FD) limits

On busy server open FD (file descriptors) limits can cause all sort of the problems. You may want to find out how many file descriptors are being used under Linux.

Check for port 80 and 443

It is possible that some other process may be using port 80 or 443. Use netstat command to list open port and their owners:
# netstat -tulpn
# netstat -tulpn | grep
# netstat -tulpn | grep ':80'

If other process using port 80 / 443, you need to stop them or assign another port to Apache.

Other techniques

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts