Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
    
thanks, it looks neatly but unfortunately did not help. apache2 still starts before mysql. i tried adding both mysql or $mysql at the end. can you suggest how can i enable logging of the startup process so i can see what's exactly going on? thans! –  pQd Dec 13 '11 at 15:02
    
@pQd I edited my answer because originally I had forgotten the END INIT INFO line. does insserv give any errors when you run it? does insserv -d -vv 2>&1 | grep apache mention that it is loading your newly created file from /etc/insserv/overrides? –  stew Dec 13 '11 at 15:09
    
i actually included the END INIT.. insserv -d -vv seems to load the data from newly created config: pastebin.com/P185Wrfm –  pQd Dec 13 '11 at 15:16
    
hmm, odd. Can you pastebin the LSB headers from both your apache2 override and the msyql init script just to check? I've tried this locally and it works for me. I guess a listing of /etc/rc2.d (or whichever runlevel you are working on) would be helpful too. –  stew Dec 13 '11 at 15:28
    
sorry... i'm a moron. your suggestion did work. thank you very much! can you suggest something i can read to feel more comfortable with the new LSBInitScripts [besides first few links from google that i'll take a look at]? –  pQd Dec 13 '11 at 15:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.