Friday, October 31, 2008

autostart apache during boot

i just finished my apache, php, mysql installation for my new server.  i used Centos 5.1. Those not started when i reboot my server. Oh..i forgot to make it autostart during boot time. 

Here the steps to auto run apache or mysql during the boot time..

run command runlevel to check your current Centos run level

Running runlevel command on my centos linux machines displays default run level as 5.You must be wondering what runlevel has to do with by autostarting apache server. There is reason for that Linux uses different run levels to boot and you should know default runlevel where you would like to configure apache to autostart during boot.

Next you have to use magic command called chkconfig on fedora to list the apache (httpd) services runlevel:

[root@node12 ~]# chkconfig --list httpd

httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

In chkconfig output off means apache (httpd) service is set with no autostart for associated runlevels. Since my default runlevel is 5 , I need to set apache to autostart in runlevel 5 using chkconfig. Here is how you can turn apache autostart for your default run level :

[root@node12 ~]# chkconfig --level 5 httpd on


If your default run level is 3 then you should use 3 in above command. You can also run 

 [root@node12 ~]# chkconfig --level 235 httpd on

to make ur apache run on level 2,3 and 5. 

Now to check if autostart is set as on during boot


Run checkconfig again :

[root@node12 ~]# chkconfig --list httpd

httpd 0:off 1:off 2:off 3:off 4:off 5:on 6:off

that's all..Centos your life!! 




No comments: