We want the apache service to start automatically upon reboot of the RHEL 6 server. In other words, how can we setup apache as a service and enable it to auto-start on reboot?
We can auto start apache as a service using the chkconfig utility. Below are the steps:
1. Become as root user on your Linux server.
# sudo su -
2. Create or copy your script under /etc/init.d. For example:
# vi /etc/init.d/httpd
3. Add script to start on boot using chkconfig utility using below commands.
# cd /etc/init.d # chkconfig --add httpd # chkconfig httpd on
4. And to Confirm script is added using chkconfig utility, run the below command :
# chkconfig --list httpd httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Disabling the service
In order to disable auto-start service then run these commands one by one:
# chkconfig httpd off # chkconfig –del httpd
chkconfig httpd off : This will disable auto-start service.
chkconfig –del httpd : This is to remove your script from chkconfig list.