Debian squeeze – startup order of services

debian-squeeze

for some reason i need to start apache2 only after mysql is running on one of the servers.

i've tried:

  • renaming scripts in /etc/rc2.d to give S0Xmysql lower number than S0Yapache2 – but it did not help.
  • editing /etc/init.d/apache2 and adding Required-Start $mysql

but still when i watch the screen at the bootup i see

INIT: Entering runlevel: 2
...
Starting web server: apache2Action 'start' failed.

and only then

Starting MySQL database server: mysqld

thx

Best Answer

At the top of /etc/init.d/apache2, you'll see the lsb-header section which looks like this:

### BEGIN INIT INFO
# Provides:          apache2
# Required-Start:    $local_fs $remote_fs $network $syslog $named
# Required-Stop:     $local_fs $remote_fs $network $syslog $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# X-Interactive:     true
# Short-Description: Start/stop apache2 web server
### END INIT INFO

You want to copy this text into a new file you'll create named /etc/insserv/overrides/apache2. Change the Required-Start line by adding "mysql" to the end of the line. then run insserv -d. You should then see that the startup link for apache2 is moved to be later than mysql.