[ubuntu-us-mi] run apache and mysql as services at startup

Jeff Hanson jhansonxi at gmail.com
Mon Sep 19 04:19:16 UTC 2011


Don't do that.  It's like using duct tape to fix a broken driveshaft.
It will cause more problems than just doing it the correct way and
will end up being reverted the next time you install an update to
apache.
On 9/18/11, Eric Beversluis <ebever at researchintegration.org> wrote:
> Here are some results. I don't know why this installation is giving me
> so much grief. I have neither the technical knowledge nor the time to be
> doing this kind of trouble-shooting. Should I just start over with a
> fresh installation?

WoW:  The difference between PC experts and everyone else is
perseverance.  I didn't learn Windows in a week (more like 20 years)
and didn't expect to learn Linux any faster (although I've come a long
way in 6).

Google for command names + Ubuntu release name + year.  For eample:
+apache2 +lucid +init +2011.

RTFM - the "man" pages. ("man 8 runlevel" or "man man" or "man -k
<command or file name to search for>".

Also see the docs in /usr/share/doc.  The compressed pages can be read
directly using Midnight Commander's viewer ("mc" package).


> /etc/default has the ff for 'apache2' and nothing for 'mysql'(nor is
> there a mysql file in /etc/rc2.d, but there is in /etc/init.d, which I
> copy below).
>
> /etc/default/apache2:

Nothing obviously wrong that I can see.  It doesn't appear to have an
"enable" entry so it may not rely on one.  A few servers do as they
want you to change default passwords and config options before they
will run (for security reasons).


> =========
> /etc/init.d/mysql (link):

I haven't used MySQL so I can't help with that.  In general,
/etc/init.d are the "old" init scripts and are just shell scripts.
They are started via symlinks in the rc#.d directories where # is the
current runlevel (usually 2).  The init process just goes through and
starts them whenever the system boots or when the runlevel changes.
The S#... symlinks start a process and the K#... end one.  The number
(#) just determines the order.  To enable one (like apache) they can
be renamed and the number changed to 100-# (or just use update-rc.d).
On my system (Lucid) the apache symlink is S91apache2.  The numbers
and scripts interact to control dependencies between processes so that
they start in the correct order.  There are limitations to what can be
done this way (and they're complicated) so Canonical is changing to
Upstart.

The /etc/init directory has Upstart jobs (the "new" init).  These have
their own programming language and are triggered on "events".  They
aren't started by symlinks.  Upstart runs the old init scripts to
maintain compatibility (IIRC).


> =========
> TRYING 'sudo update-rc.d apache2 default', I get:
> "
>      update-rc.d: warning: apache2 start runlevel arguments (none) do
> not match LSB Default-Start values (2 3 4 5)
>      update-rc.d: warning: apache2 stop runlevel arguments (none) do not
> match LSB Default-Stop values (0 1 6)
>      usage: update-rc.d [-n] [-f] <basename> remove
>        update-rc.d [-n] <basename> defaults [NN | SS KK]
>        update-rc.d [-n] <basename> start|stop NN runlvl [runlvl] [...] .
>        update-rc.d [-n] <basename> disable|enable [S|2|3|4|5]
> 		-n: not really
> 		-f: force
>

Try:
update-rc.d apache2 enable 2
or just rename the symlink manually (if it starts with a K).  My
S91apache2 (enabled) would be renamed to K9apache2 (to disable).

If it doesn't start then check the logs, /var/log/daemon.log and
/var/log/apache2/* in particular.  Also "dmesg | tail" to see any
crash reports from the kernel.

> =======
> I went into /bin/init.d/apache2 (copied below) and uncommented the
> "Default-Start" and "Default-Stop" lines. Now when I run 'sudo
> update-rc.d apache2 default' I get:

Don't do that.  That's like repairing a drive shaft with duct tape.
It will break something else and will revert the next time the apache2
package is updated.



More information about the ubuntu-us-mi mailing list