Mysql – Apache and MySQL doesn’t start at boot

apache-2.2debianMySQLstartup-scriptsupdate

I am running Debian 6 on a server. On this server I want to have an instance of Apache2 and MySQL started when the system boots.

For this purpose I know there are the init.d script and the symbolic links in the rc.d directories.

I can check the configuration using the sysv-rc-confcommand:

┌ SysV Runlevel Config   -: stop service  =/+: start service  h: help  q: quit ─┐
│                                                                               │
│ service      1       2       3       4       5       0       6       S        │
│ ----------------------------------------------------------------------------  │
│ apache2     [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]       │
│ mysql       [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]       │
│                                                                               │
└───────────────────────────────────────────────────────────────────────────────┘

So I try to reboot the machine with the reboot command. And then I test my services:

root@server:~# /etc/init.d/apache2 status
Apache2 is NOT running.
root@server:~# /etc/init.d/mysql status
MySQL is stopped..

I wanted to check the symbolic links but they look ok:

root@server:~# ls -l /etc/rc2.d/
(...)
lrwxrwxrwx 1 root root  15 Mar 12 22:12 S02mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root  13 Sep 22  2011 S02ssh -> ../init.d/ssh
lrwxrwxrwx 1 root root  17 Mar 12 22:12 S03apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root  18 Jan 24  2012 S03rc.local -> ../init.d/rc.local
(...)

Do you have any idea why this is not working?

Best Answer

Maybe you should try and use chkconfig package

apt-get install chkconfig

once done, 

chkconfig mysql on 
chkconfig apache2 on 

if for some reason doesn't work you can add

echo "/etc/init.d/mysql start" >> /etc/rc.local
echo "/etc/init.d/apache2 start"  >> /etc/rc.local

restart and test