29.11. Configure the /etc/rc.d/init.d/httpd script file

Configure your /etc/rc.d/init.d/httpd script file to start and stop Apache Web Server. Create the httpd script file, touch /etc/rc.d/init.d/httpd and add:


      #!/bin/sh
      #
      # Startup script for the Apache Web Server
      #
      # chkconfig: 345 85 15
      # description: Apache is a World Wide Web server.  It is used to serve \
      #        HTML files and CGI.
      # processname: httpd
      # pidfile: /var/run/httpd.pid
      # config: /etc/httpd/conf/httpd.conf


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

      # See how we were called.
      case "$1" in
      start)
      echo -n "Starting httpd: "
      daemon httpd -DSSL
      echo
      touch /var/lock/subsys/httpd
      ;;
      stop)
      echo -n "Shutting down http: "
      killproc httpd
      echo
      rm -f /var/lock/subsys/httpd
      rm -f /var/run/httpd.pid
      ;;
      status)
      status httpd
      ;;
      restart)
      $0 stop
      $0 start
      ;;
      reload)
      echo -n "Reloading httpd: "
      killproc httpd -HUP
      echo
      ;;
      *)
      echo "Usage: $0 {start|stop|restart|reload|status}"
      exit 1
      esac

      exit 0
    

Now, make this script executable and change its default permissions:


        [root@deep ]/# chmod 700  /etc/rc.d/init.d/httpd
      
Create the symbolic rc.d links for Apache with the command:

        [root@deep ]/# chkconfig --add httpd
      

Start your new Apache server manually with the following command:


        [root@deep ]/# /etc/rc.d/init.d/httpd start
      

        Starting httpd:                                                   [  OK  ]
      
The -DSSL option will start Apache in SSL mode. If you want to start Apache in regular mode, remove the -DSSL option near the line that reads daemon httpd.