3 # apache Apache Web Server
6 # description: Apache is a World Wide Web server. It is used to serve \
9 # pidfile: /var/run/httpd.pid
10 # config: /etc/httpd/apache.conf
12 # Source function library
13 . /etc/rc.d/init.d/functions
16 . /etc/sysconfig/network
19 [ -f /etc/sysconfig/httpd ] && . /etc/sysconfig/httpd
21 # Check that networking is up.
22 if is_yes "${NETWORKING}"; then
23 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
24 msg_network_down httpd
31 [ -z "$HTTPD_MPM" ] && HTTPD_MPM="prefork"
33 if [ -n "${HTTPD_CONF}" ]; then
34 if [ -d "${HTTPD_CONF}" ] || [ -f "${HTTPD_CONF}" ]; then
35 CFG="-f ${HTTPD_CONF}"
37 echo "error: HTTPD_CONF='$HTTPD_CONF': not a file, not a directory"
43 /usr/sbin/httpd.${HTTPD_MPM} -t $CFG $HTTPD_OPTS >/dev/null 2>&1
48 # Check if the service is already running?
49 if [ ! -f /var/lock/subsys/httpd ]; then
50 msg_starting httpd.${HTTPD_MPM}
51 daemon /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS
53 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
55 msg_already_running httpd.${HTTPD_MPM}
61 if [ -f /var/lock/subsys/httpd ]; then
62 msg_stopping httpd.${HTTPD_MPM}
63 killproc --pidfile httpd.pid httpd.${HTTPD_MPM}
64 rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
66 msg_not_running httpd.${HTTPD_MPM}
71 if [ -f /var/lock/subsys/httpd ]; then
75 msg_not_running httpd.${HTTPD_MPM}
81 # See how we were called.
90 status httpd.${HTTPD_MPM}
92 /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS -S
101 reload|force-reload|graceful)
102 if [ -f /var/lock/subsys/httpd ]; then
104 if [ $RETVAL -eq 0 ]; then
105 msg_reloading httpd.${HTTPD_MPM}
107 /usr/sbin/httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS -k graceful
109 [ $RETVAL -eq 0 ] && ok || fail
112 msg_not_running httpd.${HTTPD_MPM}
117 if [ -f /var/lock/subsys/httpd ]; then
118 msg_reloading httpd.${HTTPD_MPM}
121 if [ $RETVAL -eq 0 ]; then
122 /usr/sbin/httpd.${HTTPD_MPM} $CFG -k graceful
124 [ $RETVAL -eq 0 ] && ok || fail
127 echo >&2 "Configuration file syntax test failed. Run $0 configtest to see errors."
132 /usr/sbin/httpd.${HTTPD_MPM} -t $CFG $HTTPD_OPTS
135 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|graceful|configtest|status}"