I got this error on a fresh install when starting apache2 Ubuntu 12.10.
It's a bug in the apache2. It gets hung in the background. Here is my walkthrough to where the bugs might be in the software.
Here's the error I got:
el@titan:~$ sudo service apache2 start
* Starting web server apache2
(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
Action 'start' failed.
The Apache error log may have more information.
Address already in Use? What could be using it? Check it out:
el@titan:~$ grep -ri listen /etc/apache2
/etc/apache2/apache2.conf:# supposed to determine listening ports for incoming connections, and which
/etc/apache2/apache2.conf:# Include list of ports to listen on and which to use for name based vhosts
/etc/apache2/ports.conf: Listen 443
/etc/apache2/ports.conf: Listen 443
That means apache2 is preventing apache2 from starting. Bizarre. This will confirm:
el@titan:~$ ps -ef | grep apache2
root 1146 954 0 15:51 ? 00:00:00 /bin/sh /etc/rc2.d/S91apache2 start
root 1172 1146 0 15:51 ? 00:00:00 /bin/sh /usr/sbin/apache2ctl start
root 1181 1172 0 15:51 ? 00:00:00 /usr/sbin/apache2 -k start
root 1193 1181 0 15:51 ? 00:00:00 /bin/bash /usr/share/apache2/ask-for-passphrase 127.0.1.1:443 RSA
el 5439 5326 0 16:23 pts/2 00:00:00 grep --color=auto apache2
Yes, in this case apache2 is running, I was trying to start apache2 a second time on the same port.
What confuses me is that
service reports that apache2 is NOT running:
el@titan:~$ sudo service apache2 status
Apache2 is NOT running.
And when you query apache2ctl for its status, it hangs.
root@titan:~# /usr/sbin/apache2ctl status
**hangs until Ctrl-C is pressed.
So Ubuntu seems to be having trouble managing apache2 on bootup. Time to stop apache2:
root@titan:~# /usr/sbin/apache2ctl stop
httpd (no pid file) not running
A big clue! You try to stop apache2 and it lost the process id! So Ubuntu can't stop apache2 because it doesn't know where it is!
You would think a reboot would fix it, but it doesn't because apache2 starts on boot and hangs. The normal boot process for apache2 is not working right.
So How to fix it?
I was able to fix this by analyzing the
ps command output. Notice that the
ps command tells us that that process was started by "/etc/rc2.d/S91apache2 start".
That is the offending program that needs a swift kick.
/etc/rc2.d/S91apache2 is the symbolic link used to start apache2 for you when the computer starts. For some reason it seems to be starting apache2 and then hangs. So we'll have to tell it to not do that.
So go take a look at that
el@titan:/etc/rc2.d$ ls -l
lrwxrwxrwx 1 root root 17 Nov 7 21:45 S91apache2 -> ../init.d/apache2*
It's a symbolic link that we don't want it to be there. Do this to prevent apache2 from starting on boot:
root@titan:~# sudo update-rc.d -f apache2 remove
Removing any system startup links for /etc/init.d/apache2 ...
Reboot the computer to make sure apache2 doesn't start and hang. Ok good. Now you COULD put apache2 back the way it was, but that would make it fail again.
root@titan:~$ sudo update-rc.d apache2 defaults //(don't do this)
Adding system startup for /etc/init.d/apache2 ...
/etc/rc0.d/K20apache2 -> ../init.d/apache2
/etc/rc1.d/K20apache2 -> ../init.d/apache2
/etc/rc6.d/K20apache2 -> ../init.d/apache2
/etc/rc2.d/S20apache2 -> ../init.d/apache2
/etc/rc3.d/S20apache2 -> ../init.d/apache2
/etc/rc4.d/S20apache2 -> ../init.d/apache2
/etc/rc5.d/S20apache2 -> ../init.d/apache2
Instead, start the apache2 like this:
sudo service apache2 start
And the apache2 is back up and serving pages again. There seems to be some serious bugs with apache2/Ubuntu 12.10 that causes apache2 to start and hang. This is a workaround, I suppose the fix is to get newer versions of apache2 and Ubuntu and hope for the best.