Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache won't start -- says httpd module is loaded but isn't running

So I've been working with several Virtual Hosts on OS X 10.8.2. I'm using the Apache2 installation and MySQL to run name-based virtual hosts. They have all been working perfectly fine until last night. Suddenly, all of my virtual hosts redirect to a "Cannot connect to" page.

After fiddling around and eventually checking the error logs, I've concluded that Apache is NOT actually running. For example, ps aux | grep apache only returns the grep process. However, if I try sudo /usr/sbin/apachectl start I get "org.apache.httpd: Already loaded" in response.

I've checked my httpd.conf file and it looks perfectly fine. I can't see any changes to it. I also ran the syntax check command (which escapes my brain at the exact moment), and it returned OK. The only thing I found in my error logs, the last thing, was from yesterday, Feb 21, and it says: "[Thu Feb 21 21:46:02 2013] [notice] caught SIGTERM, shutting down"

Ever since then, my Apache errors logs contain nothing (because it's not running). I've restarted, tried restarting apache; I'm at a total loss as to why it thinks it's running even though it is not.

Any ideas?

In /var/logs/system.log when I try to start and restart Apache:

Feb 23 09:27:00 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd[8766]): Exited with code: 1
Feb 23 09:27:00 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Feb 23 09:27:10 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd[8767]): Exited with code: 1
Feb 23 09:27:10 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Feb 23 09:27:16 Baileys-MacBook-Pro.local sudo[8769]:   bailey : TTY=ttys000 ; PWD=/private/var/log ; USER=root ; COMMAND=/usr/sbin/apachectl start
Feb 23 09:27:20 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd[8772]): Exited with code: 1
Feb 23 09:27:20 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Feb 23 09:27:20 Baileys-MacBook-Pro.local sudo[8773]:   bailey : TTY=ttys000 ; PWD=/private/var/log ; USER=root ; COMMAND=/usr/sbin/apachectl restart
Feb 23 09:27:20 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd[8777]): Exited with code: 1
Feb 23 09:27:20 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Feb 23 09:27:26 Baileys-MacBook-Pro.local sudo[8778]:   bailey : TTY=ttys000 ; PWD=/private/var/log ; USER=root ; COMMAND=/usr/bin/vi system.log

This problem persists after rebooting. Ever since the other day, it will not start but believes the httpd module is loaded.

I'm trying to find out via Google, but -- does anyone know how Apache checks if it's loaded? I know a lot of services lock files to run; is it possible Apache has a lock file somewhere that's still locked despite Apache not currently running?



NOTE: I've posted this on ServerFault, as well -- I'm posting this here as well because so far I'm not getting anything on ServerFault and I've been looking at Apache posts on StackOverflow, so I'm assuming Apache questions are fine for Stack.

like image 645
Mister R2 Avatar asked Feb 23 '13 20:02

Mister R2


People also ask

Why is my Apache server not starting?

There are several reasons your Apache server might fail to run. Something could be blocking the port it uses; there could be another instance of Apache already running; or there might be an incompatibility with the version of PHP you're using in MAMP.

How do I force start httpd?

How do I restart httpd service? You can use the service or systemctl command to restart httpd server. Another option is use /etc/init. d/httpd service script under Linux or Unix-like systems.

How do I run Apachectl?

To start and stop IBM HTTP Server, use the apachectl command. The apachectl command is located in the bin subdirectory within the IBM HTTP Server installation directory. If that directory is not in your PATH, the full path should be given on the command line. Log on as the Web server user ID.


2 Answers

I can reproduce the issue (kinda) by starting Apache when there's another process already listening on the same port that Apache wants to bind to (usually that's port 80). So check if there's perhaps another process listening on that port:

sudo lsof -i tcp:80 | grep LISTEN

EDIT: Perhaps easier: you can start Apache manually in debug mode to see what the reason is it won't start:

sudo /usr/sbin/httpd -k start -e Debug -E /dev/stdout

In my case (something already listening on port 80), it will produce:

(48)Address already in use: make_sock: could not bind to address 0.0.0.0:80
like image 98
robertklep Avatar answered Oct 11 '22 14:10

robertklep


In my case I got:

(2)No such file or directory: httpd: could not open error log file /private/var/log/apache2/error_log. Unable to open logs

Creating the directory apache2 made it running.

like image 31
Markus Zeller Avatar answered Oct 11 '22 13:10

Markus Zeller