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.
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop