Apache on ubuntu leaves a legacy

Not a good legacy. The default init script (/etc/init.d/apache2) that is put in place when you install apache2 via the usual apt-get doesn't actually work if your apache instance is listening on more than one port. For example if you've enable ssl with a2enmod ssl and are listening on both port 80 for http and 443 for https, it won't work.

Long story short -- it will cause funkiness w/your system and will eventually prevent apache from starting / restarting normally, spewing errors like these (among others potentially).

You can easily verify if your system is suffering your problem by doing the following:

1) verify apache is not running: netstat -lntp (you shouldn't see anything w/apache in the PID/Program column) and "pgrep apache" should also display nothing.

2) start apache normally: /etc/init.d/apache2 start

3) stop apache normally: /etc/init.d/apache2 stop

Now normally at this point there should be no apache related processes running, but if you are suffering from this bug you should see a slew of apache processes from: "pgrep apache" -- and that list only grows with each restart, or stop and start. Eventually leading to errors like these:

Wed Mar 05 21:49:24 2008] [notice] mod_python: using mutex_directory /tmp [Wed Mar 05 21:49:24 2008] [error] (28)No space left on device: mod_python: Failed to create global mutex 6 of 8 (/tmp/mpmtx68006). [Wed Mar 05 21:49:24 2008] [error] mod_python: We can probably continue, but with diminished ability to process session locks. [Wed Mar 05 21:49:24 2008] [error] mod_python: Hint: On Linux, the problem may be the number of available semaphores, check 'sysctl kernel.sem' [Wed Mar 05 21:49:25 2008] [emerg] (28)No space left on device: Couldn't create accept lock (/var/lock/apache2/accept.lock.6800) (5)

The official launchpad bug report has a few good suggestions on possible fixes, including this that caught my attention, from Juergen Kreileder :

The cleaner work-around is to just replace "$APACHE2CTL graceful-stop" with "$APACHE2CTL stop".

This is in reference to the apache_stop() function, with the specific line currently at 102 (/etc/init.d/apache2) -- So these lines (with context)

apache_stop() { if `$APACHE2 -t > /dev/null 2>&1`; then # if the config is ok than we just stop normaly $APACHE2CTL graceful-stop

would look like this instead:

apache_stop() { if `$APACHE2 -t > /dev/null 2>&1`; then # if the config is ok than we just stop normaly $APACHE2CTL stop

I run Ubuntu gusty gibbon on both my server and workstation -- but this is just the latest on a growing list of bugs that are Ubuntu specific -- and I'm starting to lose patience.

Ubuntu Wall of Shame

  1. Apache on Ubuntu leaves a legacy (init.d broken)
  2. trac on 64bit Gusty Broken
  3. Flash on 64bit Ubuntu broken