How to automatically restart Apache on system reboot time ?

Saturday, February 28, 2015

How to automatically restart Apache on system reboot time ?

To Start Apache at Boot Time, need to do below process. The Apache server is started as root because it uses port 80 (lower than 1024) but it spawns processes that run as "nobody".

Save the following script as /etc/init/apache. it will automatically be read and run at boot time. Check the log files if it does not start properly.

Make a link to it from /etc/rc5.d such as:
cd /etc/rc5.d
sudo ln -s ../init.d/apache S72apache

----------------------------  /etc/init.d/apache  ------------------------
#!/bin/bash
#
# apache        
#
# chkconfig: 
# description:  Start up the Apache web server.

# Source function library.
. /etc/init.d/functions


RETVAL=$?
APACHE_HOME="/usr/apps/apache/apache"

case "$1" in
 start)
 if [ -f $APACHE_HOME/bin/apachectl ]; then
     echo $"Starting Apache"
        $APACHE_HOME/bin/apachectl start
    fi
 ;;
 stop)
 if [ -f $APACHE_HOME/bin/apachectl ]; then
     echo $"Stopping Apache"
        $APACHE_HOME/bin/apachectl stop
    fi
  ;;
 *)
  echo $"Usage: $0 {start|stop}"
 exit 1
 ;;
esac

exit $RETVAL
-----------------------  end of /etc/init.d/apache  ----------------------

0 comments:

About This Blog

Lorem Ipsum

  © Copyright 2009 Linux-HelpLine.Blogspot.com

Back to TOP