Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Apache is running; however, it reports that it is not, and it will not restart.

# /etc/init.d/httpd status
httpd.worker is stopped

# /usr/sbin/lsof -iTCP:80 
COMMAND    PID   USER   FD   TYPE DEVICE SIZE NODE NAME
httpd.wor 1169   root    3u  IPv6   2974       TCP *:http (LISTEN)
httpd.wor 1211 daemon    3u  IPv6   2974       TCP *:http (LISTEN)
httpd.wor 1213 daemon    3u  IPv6   2974       TCP *:http (LISTEN)
httpd.wor 1215 daemon    3u  IPv6   2974       TCP *:http (LISTEN)
httpd.wor 1352 daemon    3u  IPv6   2974       TCP *:http (LISTEN)

#/etc/init.d/httpd restart
Stopping httpd:                                            [FAILED]
Starting httpd: [Wed Mar 24 10:33:51 2010] [warn] module proxy_ajp_module is already loaded, skipping
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
                                                           [FAILED]

OS: Linux DISTRO: CENTOS 5
Restarting the server didn't help, nor did killing apache and starting it.

Any idea what is causing this inconsistency?

share|improve this question
    
Have you got two instances of apache installed? –  ar. Mar 24 '10 at 14:42
add comment

migrated from stackoverflow.com Mar 24 '10 at 14:58

This question came from our site for professional and enthusiast programmers.

4 Answers

Ususally the init.d scripts use files to store the PIDs of the daemons started, e.g. /var/run/httpd.pid or something similar. It can be that either the script stores the wrong PID, or a stale PID, or there is a permission problem, and the script cannot create the file in the first place.

share|improve this answer
add comment

I'm guessing that you have a stale PID file from a previous launch of Apache. I don't have access to a CentOS system, but on my Fedora 11 machine this file is in /var/run/httpd/httpd.pid - you can check your location by searching for "pidfile" in /etc/init.d/httpd (I'm assuming you are using a version of Apache installed from RPM; if not and you have apache in /usr/local/apache2 or similar, the PID file goes in /usr/local/apache2/logs).

Stop Apache, delete the stale PID file, then restart and you should be OK.

share|improve this answer
add comment

The init.d file is typically just a shell script -- it's likely calling apachectl to start and stop the process. Check to see what command it's sending to stop the process, and see what happens when you try running whatever command it uses directly, without the init.d file.

If that still doesn't work, check your webserver's error logs, to see if there's anything useful in there.

For debugging, you can also try sending using the apachectl graceful command -- it'll reload the config and restart children processes without taking down the main process. (the problem is that it means that there's a few config changes that won't take effect, but unless you're doing tuning, it probably won't matter)

share|improve this answer
add comment

I'm guessing that you have two different init scripts starting apache up, and that the different init scripts are using different pid-files.

What happens if you do killall -9 httpd and then start Apache via /etc/init.d/httpd start?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.