Apache fails to start after reboot due to missing /var/run/apache2 directory when SSL is enabled

Bug #603211 reported by timdaman
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
apache2 (Ubuntu)
Won't Fix
Medium
Unassigned

Bug Description

Binary package hint: apache2

For some reason after I rebooted my apache2 server the /var/run/apache2 directory disappeared. This directory is needed to support mod_ssl which makes use of it to store "SSLSessionCache" and "SSLMutex". Apache2 cannot be started with ssl enabled and the /var/run/apache2 is directory missing. It will log the following message

[Thu Jul 08 00:15:15 2010] [error] (2)No such file or directory: Cannot create SSLMutex with file `/var/run/apache2/ssl_mutex'
Configuration Failed

The solution is to recreat this directory. I am using the following code stub

[ -d /var/run/apache2 ] || mkdir /var/run/apache2

There are several solutions to this issue

1) Ensure /var/run/apche2 doesn't get deleted on reboot
2) Ensure startup scripts verify /var/run/apche2 exists and create it if missing
3) In /etc/apache2/mods-available/ssl.conf adjust "SSLSessionCache" and "SSLMutex" to store these in a more permanent location.

I also have run into this issue while using the OCF startup script included with the "heartbeat" package.

Revision history for this message
Stefan Fritsch (sf-sfritsch) wrote :

This should be fixed since 2.2.4-2. Which version are you using?

Revision history for this message
timdaman (timdaman-gmail) wrote : Re: [Bug 603211] Re: Apache fails to start after reboot due to missing /var/run/apache2 direcotry when ssl is enabled

2.2.8-1 from what I can see. Full details can be found below.
--Tim

root@XXXXXX:/var/log# dpkg -l | grep apache
ii apache2 2.2.8-1ubuntu0.15 Next
generation, scalable, extendable web se
ii apache2-mpm-worker 2.2.8-1ubuntu0.15 High
speed threaded model for Apache HTTPD
ii apache2-utils 2.2.8-1ubuntu0.15
utility programs for webservers
ii apache2.2-common 2.2.8-1ubuntu0.15 Next
generation, scalable, extendable web se
ii libapache2-mod-jk 1:1.2.25-2
Apache 2 connector for the Tomcat Java servl
root@q9web3:/var/log# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.4 LTS"
root@XXXXXX:/var/log# apache2 -v
Server version: Apache/2.2.8 (Ubuntu)
Server built: Mar 9 2010 21:51:02

--Tim

On Thu, Jul 8, 2010 at 1:28 PM, Stefan Fritsch <email address hidden> wrote:

> This should be fixed since 2.2.4-2. Which version are you using?
>
> --
> Apache fails to start after reboot due to missing /var/run/apache2
> direcotry when ssl is enabled
> https://bugs.launchpad.net/bugs/603211
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in “apache2” package in Ubuntu: New
>
> Bug description:
> Binary package hint: apache2
>
> For some reason after I rebooted my apache2 server the /var/run/apache2
> directory disappeared. This directory is needed to support mod_ssl which
> makes use of it to store "SSLSessionCache" and "SSLMutex". Apache2 cannot be
> started with ssl enabled and the /var/run/apache2 is directory missing. It
> will log the following message
>
> [Thu Jul 08 00:15:15 2010] [error] (2)No such file or directory: Cannot
> create SSLMutex with file `/var/run/apache2/ssl_mutex'
> Configuration Failed
>
> The solution is to recreat this directory. I am using the following code
> stub
>
> [ -d /var/run/apache2 ] || mkdir /var/run/apache2
>
> There are several solutions to this issue
>
> 1) Ensure /var/run/apche2 doesn't get deleted on reboot
> 2) Ensure startup scripts verify /var/run/apche2 exists and create it if
> missing
> 3) In /etc/apache2/mods-available/ssl.conf adjust "SSLSessionCache" and
> "SSLMutex" to store these in a more permanent location.
>
> I also have run into this issue while using the OCF startup script included
> with the "heartbeat" package.
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/603211/+subscribe
>

Revision history for this message
Stefan Fritsch (sf-sfritsch) wrote : Re: Apache fails to start after reboot due to missing /var/run/apache2 direcotry when ssl is enabled

That's strange. /usr/sbin/apache2ctl should contain "mkdir -p /var/run/apache2" and the init script should only call apache2ctl. Can you check that? And if apache2 failed to start after a boot, you should be able to restart it (using the init script or apache2ctl) without creating the directory.

Maybe something is still cleaning /var/run while apache is already starting.

Revision history for this message
Clint Byrum (clint-fewbar) wrote :

I was unable to reproduce this by installing apache2, enabling ssl, hitting the site a few times, and then rebooting the machine.

apache2ctl does clear out /var/run/apache2/*ssl_scache* .. but thats the closest thing I could find to something clearing out /var/run/apache2.

Marked as Incomplete.

Changed in apache2 (Ubuntu):
status: New → Incomplete
importance: Undecided → Medium
Revision history for this message
timdaman (timdaman-gmail) wrote : Re: [Bug 603211] Re: Apache fails to start after reboot due to missing /var/run/apache2 direcotry when ssl is enabled

In reviewing your email with my teamyou are right. I am pretty sure the
admin how ran into the bug used the OCF script instead of the init.d to try
to match what "heartbeat" is doing. Looking at ocf it doesn't use
apache2ctl, it uses /usr/sbin/apache2. I will retract my bug report from you
and add your additional information the the heartbeat report. My appoligies
for the false accusation and thank you very much for your help.
--Tim

On Fri, Jul 9, 2010 at 1:51 PM, Clint Byrum <email address hidden> wrote:

> I was unable to reproduce this by installing apache2, enabling ssl,
> hitting the site a few times, and then rebooting the machine.
>
> apache2ctl does clear out /var/run/apache2/*ssl_scache* .. but thats
> the closest thing I could find to something clearing out
> /var/run/apache2.
>
> Marked as Incomplete.
>
> ** Changed in: apache2 (Ubuntu)
> Status: New => Incomplete
>
> ** Changed in: apache2 (Ubuntu)
> Importance: Undecided => Medium
>
> --
> Apache fails to start after reboot due to missing /var/run/apache2
> direcotry when ssl is enabled
> https://bugs.launchpad.net/bugs/603211
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in “apache2” package in Ubuntu: Incomplete
>
> Bug description:
> Binary package hint: apache2
>
> For some reason after I rebooted my apache2 server the /var/run/apache2
> directory disappeared. This directory is needed to support mod_ssl which
> makes use of it to store "SSLSessionCache" and "SSLMutex". Apache2 cannot be
> started with ssl enabled and the /var/run/apache2 is directory missing. It
> will log the following message
>
> [Thu Jul 08 00:15:15 2010] [error] (2)No such file or directory: Cannot
> create SSLMutex with file `/var/run/apache2/ssl_mutex'
> Configuration Failed
>
> The solution is to recreat this directory. I am using the following code
> stub
>
> [ -d /var/run/apache2 ] || mkdir /var/run/apache2
>
> There are several solutions to this issue
>
> 1) Ensure /var/run/apche2 doesn't get deleted on reboot
> 2) Ensure startup scripts verify /var/run/apche2 exists and create it if
> missing
> 3) In /etc/apache2/mods-available/ssl.conf adjust "SSLSessionCache" and
> "SSLMutex" to store these in a more permanent location.
>
> I also have run into this issue while using the OCF startup script included
> with the "heartbeat" package.
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/603211/+subscribe
>

Revision history for this message
Richard Porteous (richard-porteousclan) wrote : Re: Apache fails to start after reboot due to missing /var/run/apache2 direcotry when ssl is enabled

I have this same bug on a development desktop (i believe)
Server version: Apache/2.2.14 (Ubuntu)
Server built: Apr 13 2010 19:28:27
Server's Module Magic Number: 20051115:23
Server loaded: APR 1.3.8, APR-Util 1.3.9
Compiled using: APR 1.3.8, APR-Util 1.3.9
Architecture: 32-bit
Server MPM: Prefork
  threaded: no
    forked: yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT=""
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"

/var/run/apache2 doesn't exist and is deleted when manually created.
Difference, the Apache server seems to start on boot about half the time.

I am also running webmin.
I have the default desktop install (Ubuntu 10.04) and then the apache mpm prefork with php installed.
I use localhost and then used webmin to create the aliases for the php web apps under localhost.

No I'm not sure what the logs say and may need to be given info on which logs you wish me to retrieve or what additional modules to add.

Revision history for this message
timdaman (timdaman-gmail) wrote :

I think my mistake is using
/usr/sbin/apache2
to start and stop apache rather than
/usr/sbin/apache2ctl

/usr/sbin/apache2ctl does housekeeping including creating /var/run/apache2. It is a shell script that transparently wraps the apache2 command. From what I have found it should take all the same arguments and passs them off to apache2 after taking care of it's housekeeping.

Revision history for this message
Chuck Short (zulcss) wrote :

You should be using apache2ctl to stop and start your server.

Changed in apache2 (Ubuntu):
status: Incomplete → Won't Fix
Revision history for this message
Brad Jones (brad-jones) wrote :

For those reaching this page from the comment on the Linux-HA resource-agents repository, see https://bugs.launchpad.net/ubuntu/+source/cluster-agents/+bug/980180 for the related Ubuntu package fixes.

Revision history for this message
Jure Sah (dustwolfy) wrote :

This bug is not invalid, using "service apache2 restart", which I belive is the proper procedure for restarting the apache2 server, the server fails to start due to the missing folder.

pataquets (pataquets)
summary: Apache fails to start after reboot due to missing /var/run/apache2
- direcotry when ssl is enabled
+ directory when SSL is enabled
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.