• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 426
  • Last Modified:

how to setup apache webserver to start from OS boot in linux

how to setup apache webserver to start from OS boot in linux

i am using apache 2.2.17 on centos 5.7 which is equilent to redhat 5.7
my apache instance is running under /app/local/apache2.2.17


0
wasman
Asked:
wasman
  • 2
  • 2
  • 2
1 Solution
 
Steven CarnahanNetwork ManagerCommented:
According to http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-apache-startstop.html


By default, the httpd service does not start automatically at boot time. If you would wish to have Apache startup at boot time, you will need to add a call to apachectl in your startup files within the rc.N directory. A typical file used is rc.local. As this starts Apache as root, it is recommended to properly configure your security and authentication before adding this call.

You can also configure the httpd service to start up at boot time, using an initscript utility, such as /sbin/chkconfig, /usr/sbin/ntsysv, or the Services Configuration Tool program.

0
 
xtermCommented:
If you're running a custom instance of Apache, you won't have the normal init scripts in /etc/init.d

You need to create one yourself, or get one from the samples directory.

Do "find /app/local/apache2.2.17 | grep init"  - do you see a file called httpd.init or apache.init?  If so, you can copy that into /etc/init.d/httpd and use that as your new startup script.  Then you can simply do "/sbin/chkconfig --levels 2345 httpd on" and it will enable it on all subsequent boots.

Alternatively, you can simply put the full command that you use now in /etc/rc.local (you will likely have to create this because it doesn't exist by default anymore.)  So:

touch /etc/rc.local
chmod 755 /etc/rc.local
<open /etc/rc.local in text editor and add the following line>
/app/local/apache2.2.17/bin/apachectl start

(or whatever you use to start your server normally)
0
 
wasmanIT AnalystAuthor Commented:
Thanks you
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
wasmanIT AnalystAuthor Commented:
xterm
what is the --levels 2345 ? can you please explain it more

i got this from man pages , but couldn't understand

 --level levels
              Specifies the run levels an operation should pertain to. It is given as a string of numbers from 0 to 6. For example, --level 35 specifies
              runlevels 3 and 5.
0
 
xtermCommented:
Runlevel 1 is single user mode.
Runlevel 6 is system shutdown.

Runlevel 3 is the normal multiuser environment
Runlevel 5 is the graphical (X-windows) environment.

The system boots into your environment as specified by inittdefault in /etc/inittab (usually 3 or 5)

But since the system init scripts don't really know for sure which runlevel people will choose, the safest bet is to tell Apache (or any process) 2345 which really means "start me up in any of runlevels 2 or 3 or 4 or 5" and then also "terminate me in runlevels 1 or 6".

Make sense?
0
 
Steven CarnahanNetwork ManagerCommented:
The runlevels are:

0 - System halt; no activity, the system can be safely powered down.
1 - Single user; rarely used.
2 - Multiple users, no NFS (network filesystem); also used rarely.
3 - Multiple users, command line (i.e., all-text mode) interface; the standard runlevel for most Linux-based server hardware.
4 - User-definable
5 - Multiple users, GUI (graphical user interface); the standard runlevel for most Linux-based desktop systems.
6 - Reboot; used when restarting the system

So --levels 2345 mean it applies to all but single user and reboot.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now