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
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
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:
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.
- Use search engine to find out solution for exact error messages.
- Search Apache mailing lists and vendor support forums for the error messages.
- Debug problem using strace and other tools.
|Category||List of Unix and Linux commands|
|Firewall||Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04|
|Network Utilities||dig • host • ip • nmap|
|OpenVPN||CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04|
|Package Manager||apk • apt|
|Processes Management||bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time|
|Searching||grep • whereis • which|
|User Information||groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w|
|WireGuard VPN||CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04|