27 hours ago
As the title says, when I run sudo service apache2 restart, the message returned says that Apache is already running. However, the service is stopped (if milliseconds later).
sudo service apache2 restart
Apache is already running
If I run sudo service apache2 start, everything works fine. I assume the script isn't waiting (long enough) for the process to end... I have two other servers (they're all 12.04) with the same config, exact same init file (I did a diff), and they don't exhibit this behavior.
sudo service apache2 start
Also interesting is that when I start|stop|reload, they don't return the [OK] message. What gives?
start|stop|reload
[OK]
6 hours ago
It's possible for apache to get stuck and forget to remove its PID file (if it crashes, say).
Check if the file /var/run/apache2/apache2.pid exists. If it does, rm it.
/var/run/apache2/apache2.pid
rm
Also check if there are apache processes running:
ps auxwww | grep apache
If there are, kill -9 them. Then you should be able to start apache via /etc/init.d/apache2 start.
kill -9
/etc/init.d/apache2 start