I ran into this problem when I installed apache from source, but then tried to run
$ sudo /etc/init.d/httpd restart
which used a pre-installed version of apache. The stop directive in the /etc/init.d/httpd file did not delete the httpd.pid file created when the original version of apache was launched.
To determine if this is also the cause of your problem, find the httpd.pid file that will be installed at startup
$ sudo apachectl start
If you installed from the source, and apache2 lives in / usr / local / apache 2, then the httpd.pid file must be created in / usr / local / apache 2 / logs. When you stop apache by running
$ sudo apachectl stop
This file must be deleted. Therefore, to check if the httpd.pid file caused your problem, run apache by calling
$ sudo apachectl start
and find the httpd.pid file. Then try stopping apache using
$ sudo /etc/init.d/httpd stop
If the source httpd.pid file is still present, that is why apache cannot start when you use
$ sudo /etc/init.d/httpd start
In order for my /etc/init.d/httpd file to work correctly, I explicitly put the apachectl call into the start and stop methods:
#!/bin/bash # /etc/init.d/httpd # # Path to the apachectl script, server binary, and short-form for messages. apachectl=/usr/local/apache2/bin/apachectl httpd=/usr/local/apache2/bin/httpd pid=/usr/local/apache2/logs/httpd.pid prog=httpd RETVAL=0 start() { echo -n $"Starting $prog: " $apachectl -k start RETVAL=$? echo return $RETVAL } stop() { echo -n $"Stopping $prog: " $apachectl -k stop RETVAL=$? echo }
littleforest
source share