• 4
name Punditsdkoslkdosdkoskdo

How do I get a Apache to startup at bootime on Linux?

I have installed Apache 2 from source on my Linux box. apachectl -k start works just fine, but how do I get Apache to start at boot time?

This is on a Red Hat Linux distribution:

Linux <hostname> 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux


As you have installed by source there will not be an init script installed in the /etc/init.d/ directory. The apachectl binary is designed to be compatible with standard init script options so you may well be able to simply symlink to it rather than creating a wrapper script (e.g ln -s /usr/local/sbin/apachectl /etc/init.d/apache)

You can then follow the procedures outlined in the other posts for adding links to invoke the init script at the correct runlevels.

Citation: Apache Documentation

Starting at Boot-Time

If you want your server to continue running after a system reboot, you should add a call to apachectl to your system startup files (typically rc.local or a file in an rc.N directory). This will start Apache as root. Before doing this ensure that your server is properly configured for security and access restrictions.

The apachectl script is designed to act like a standard SysV init script; it can take the arguments start, restart, and stop and translate them into the appropriate signals to httpd. So you can often simply link apachectl into the appropriate init directory. But be sure to check the exact requirements of your system.

  • 0
Reply Report

You want to add its init script to the appropriate run level. The init script is typically /etc/init.d/apache2 where you could manually run /etc/init.d/apache2 start to start it.

On Gentoo you would write:

rc-update add apache2 default

On Ubuntu/Debian this works:

sudo update-rc.d apache2 defaults

On Red Hat Linux/Fedora/CentOS a little googling shows this:

chkconfig --add httpd

It varies a little bit from distribution to distribution , but the idea is usually the same. Basically, all these commands make a symbolic link from /etc/init.d/ to the appropriate run-level folder in /etc/.

  • 0
Reply Report