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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • doym molina May 1, 2009 @ 2:16

    affter installing apache it cant me to find way..thanks

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum