How to Start a Daemon Automatically in Linux

By | August 17, 2010

If you need to start anything automatically in Linux, you should alter some files that are processed during system startup. There are lots of ways to do this; I will show you how to start Apache automatically. Note, that this installation of Apache does not allow to start it using chkconfig httpd on.

In order to setup automatic start, we will have to deal with /etc/init.d/rc.local . This is the file, that is processed on system startup and it will allow you to run anything you like. We need to start Apache using /usr/local/apache2/bin/apachectl start. Let’s add this string to the end of your /etc/init.d/rc.local

# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don’t
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/usr/local/apache2/bin/apachectl start

That’s all! Now your httpd daemon will be automatically started at boot. You can start any daemon this way. If you know any more methods to start daemons, please, add them in comments.