Mister R2
Mister R2

Reputation: 881

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.

Upvotes: 6

Views: 9756

Answers (4)

Badger
Badger

Reputation: 36

robertklep's pointer:

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

solved a related problem for me. Same symptoms, different cause, I think. I set up a test virtual host with SSL & a self-signed certificate.

I had generated a private key with a passphrase. So httpd was waiting for a passphrase (which I wasn't supplying). When I started with the debug option, I got the prompt, supplied the passphrase & httpd started up.

So, will redo the private key without a passphrase...

Upvotes: 0

user1300830
user1300830

Reputation: 83

Do not know if this is relevant, but since I faced the same problem and I found an alternate solution, let me put in my 2c anyway.

Looked into this post when I got the same issue. Turns out that the httpd.conf file was the culprit. I had changed it to install something. Although I removed the installer files, I forgot to change the httpd.conf back. I hope you did not face the same problem.

Regarding question on port 80, I had seen skype hog the port as well as 443, (God knows for what) and I had better results after I turned it off. Make sure you do no have skype running on port 80 .

Upvotes: 0

Markus Zeller
Markus Zeller

Reputation: 9145

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.

Upvotes: 1

robertklep
robertklep

Reputation: 203534

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

Upvotes: 19

Related Questions