Best way to troubleshoot apache not starting?

We have recently gotten a backup server to mirror all our data onto in case the primary server goes down.

I've gotten all the sites data updated through rsync, and all the apache config and databases updated. Both machines are on Ubuntu 9 (9.04 on the primary, 9.10 on the backup).

So everything seems synced up for the most part at this point (still need to figure out user syncing), and I try to start Apache. I get

* Starting web server apache2                                       [fail]

Nothing else indicating what the problem could be.

I know I don't have enough info to expect a solution from you guys, so I'd just like to know where I can go from here to further investigate this issue. Would there be any error logs for this?

Thanks!


Solution 1:

In some specific cases, a log entry will not be written to disk -- this can occur if logs don't exist, for example, or Apache simply cannot write to the log files due to permissions issues, etc. In such cases, the best way to diagnose an error is to use `strace':

[root@server ~]# strace -Ff apachectl start

While the output will be quite verbose, if Apache fails to start for any reason, you'll see a write() at the tail end with the contents of what would be entered in the logs with the reason it's failing (if it's not logging why in the error log, don't be surprised if the error message contains "Cannot open log" with the path to the log ;).

Though looking at your comment regarding mod_fcgid, I'd suggest reviewing the Apache configuration and examining references to mod_fcgid -- it sounds like it's trying to open a literal "mod_fcgid" file as opposed to loading the module.

Solution 2:

httpd -t will test the syntax of your configuration files and spit out any errors to the terminal.

Solution 3:

Any errors should be printed to the error logs (often at /var/log/http/error_logs. Grep for ErrorLog in your httpd.conf to find out where.

I recommend using two windows. Do a 'tail -f error_log' in one window, and use another window to run the 'apachectl restart' command. After you find the error, update your answer here with the error message.

Solution 4:

I had similar problem with debug apache server on Mac OS, so decided to share my experience and save others some time I found the following very helpful:

  1. locate logs:

apachectl -S | grep log

  1. in the output you will find some logs files you can start look for the errors example:

tail -n 15 /var/log/apache2/ssl_engine.log

In case there are more than 1 log file continue tailing them until you find the error causing apache to not start