I tried to reproduce how the system got in this situation and wasn’t able to. I did find the system in the same state as you reported it, but I couldn’t figure out how it got like that.
Basically when you ran “apachectl start”, Apache was already running. When Apache is being started (ie: apachectl start), it first checks to see if it is already running by checking or a PID file (Process ID file). If it sees a file, it will report this:
staging-aops:/var/run# apachectl start
httpd (pid 23390) already running
In this case, Apache *WAS* running, but there was NO PID file to be found, so Apache assumed it was OK to start. So it began to start but noticed that it couldn’t bind to port 80 because that port was already in-use by another process (which was Apache), and that’s the error message you received:
(98)Address already in use: make_sock: could not bind to address [::]:80
So what I had to do was manually kill Apache (given there wasn’t a PID file so it didn’t think it was even running), then I started Apache, noticed it created a PID file, then I stopped Apache (and noticed the PID file was deleted, as it was supposed to be). I then started Apache again and it created the PID file just fine and started.
I was not able to reproduce the problem where Apache was running yet the PID file didn’t exist. I am not sure how this is happening. The PID file is located at: /var/run/apache2.pid. Did someone delete the PID file in an effort to fix a problem? Sometimes that is required. If Apache were to be killed or somehow die and the PID file didn’t get cleaned up (deleted), then the PID file will have to be manually deleted before Apache can be started. But in this case it was the reverse – Apache WAS running w/no PID file.
To fix this in the future, you can:
1) ps -ef | grep apache2 | grep root | grep -v grep (which should output something like this): root 23741 1 0 13:54 ? 00:00:00 /usr/sbin/apache2 -k start
NOTE: The reason I grepped for “root” was because Apache uses the ROOT user for the initial parent process. This gives Apache the authority to do its job, running as user ROOT, and each subsequent Apache process that is spawned (child process) is now running as the “www-data” user. In order to kill all Apache processes in one step, you want to kill the parent (which is the only one running as user “root”). Killing that PID should also kill all child processes
The number to the RIGHT of “root” (23741, in this example), is the PID#. You can then do:
2) kill -9 23741 (PID will vary each and every time you perform these steps, so do not try and reuse the 23741 number but the actual number from step# 1
3) rm /var/run/apache2.pid (Make sure NO PID file exists - it shouldn't, but just in case)
4) apachectl start
If you have this issue again, going through those 4 steps should surely fix the problem.
Apache is running now and there is a PID file now – so all should be good. You can “apachectl stop”, “apachectl start” or “apachectl restart” and all are working now.