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/conf/access.conf
11 # config: /etc/httpd/conf/httpd.conf
12 # config: /etc/httpd/conf/srm.conf
15 # Source function library
16 . /etc/rc.d/init.d/functions
19 . /etc/sysconfig/network
22 [ -f /etc/sysconfig/apache ] && . /etc/sysconfig/apache
24 # Check that networking is up.
25 if is_yes "${NETWORKING}"; then
26 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
27 # nls "ERROR: Networking is down. %s can't be run." <service>
28 msg_network_down httpd
35 [ -z "$HTTPD_MPM" ] && HTTPD_MPM="prefork"
36 [ -z "$HTTPD_CONF" ] && HTTPD_CONF="/etc/httpd/httpd.conf"
37 if [ -d "$HTTPD_CONF" ]; then CFG="-d $HTTPD_CONF"
38 elif [ -f "$HTTPD_CONF" ]; then CFG="-f $HTTPD_CONF"
42 # See how we were called.
45 # Check if the service is already running?
46 if [ ! -f /var/lock/subsys/httpd ]; then
47 msg_starting httpd.${HTTPD_MPM}
48 daemon httpd.${HTTPD_MPM} $CFG $HTTPD_OPTS
50 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
52 msg_already_running httpd.${HTTPD_MPM}
57 if [ -f /var/lock/subsys/httpd ]; then
58 msg_stopping httpd.${HTTPD_MPM}
59 if [ -f /var/run/httpd.pid ]; then
60 PID=$(filter_chroot `cat /var/run/httpd.pid`)
61 if [ -z "$PID" ]; then
67 daemon httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -k stop
69 # Wait for httpd to really stop
70 if [ ! $PID -eq 0 -a $RET -eq 0 ]; then
71 show "Waiting for httpd to stop"
73 while ps -o command $PID | grep -q ^httpd
79 # Delete pidfile only when apache was called successfully
80 if [ $RET -eq 0 ]; then
81 rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
84 msg_not_running httpd.${HTTPD_MPM}
88 status httpd.${HTTPD_MPM}
90 /usr/sbin/httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -S
96 reload|force-reload|graceful)
97 if [ -f /var/lock/subsys/httpd ]; then
98 msg_reloading httpd.${HTTPD_MPM}
99 daemon httpd.${HTTPD_MPM} -f /etc/httpd/httpd.conf -k graceful
102 msg_not_running httpd.${HTTPD_MPM} >&2
107 msg_usage "$0 {start|stop|restart|reload|force-reload|graceful|status}"