On my Ubuntu 10.04.4 server apache2 2.2.14 is installed. A few months ago starting apache2 at boot worked fine.
Now I've found out that after a reboot apache2 doesn't start automatically anymore.
The init.d script is present and should be the one from the default installation:
root@ser:~# ls /etc/init.d | grep apache
apache2
the runlevel startups are also set (using update-rc.d apache2 defaults
):
root@ser:~# find /etc/rc* -name *apache*
/etc/rc0.d/K20apache2
/etc/rc1.d/K20apache2
/etc/rc2.d/S20apache2
/etc/rc3.d/S20apache2
/etc/rc4.d/S20apache2
/etc/rc5.d/S20apache2
/etc/rc6.d/K20apache2
Checking the status after reboot results in:
root@ser:~# service apache2 status
Apache is NOT running.
ps aux | grep apache
is also empty.
Looking into /var/log/apache/error.log
there are no entries at boot time. cat /var/log/syslog | grep apache
is also empty and syslog doesn't contain any suspiscious entries.
Starting apache after boot manually with service apache2 start
works fine and doesn't output any errors.
Update 1:
The /etc/init.d/apache2
script has the following header/requirements:
### BEGIN INIT INFO
# Provides: apache2
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Start/stop apache2 web server
### END INIT INFO
And the services being started are:
root@ser:~# ls /etc/rc2.d/
README S10sysklogd S20apache2 S20denyhosts S20hashcash-milter S20ido2db S20modules_dep.sh S20postfix S20saslauthd S20vzquota S50rsync S99rc.local
S09hostname_vps S15bind9 S20exim4 S20icinga S20memcached S20opendkim S20psad S20xinetd S23ntp S99ondemand
How can I find out why apache2 isn't getting started at boot?
Found the problem:
In short: my web page tried to connect to MySQL, but MySQL wasn't running at this time. Thus apache failed to start.
I changed the following line in
/etc/init.d/apache2
to log startup problem to syslog:to
After booting check your
/var/log/syslog
for entries starting withapache_start
.The next problem: how can I force apache to start after mysql. See here: Force apache start after mysql
Additional info: I use Perl Catalyst Framework.
Here is the error output from apache init script:
I think the Syntax error is caused by the previous error. Because line 10 is:
and works fine if mysql running.
I didn't found out yet why the localization module connects at startup. We have other webpages with same module which don't have this problem/connect at startup. Since it can't connect a following disconnect causes an exception in Perl which aborts the apache2crl start command. (That's what I guess)