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 "Apache 2.2 Web Server"
31 SVC_NAME="Apache 2.2 Web Server"
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"
44 /usr/sbin/httpd -t $CFG $HTTPD_OPTS 2>&1
48 # wrapper for configtest:
52 if [ $details -eq 1 ]; then
53 # run config test and display report (status action)
54 show "Checking %s configuration" "$SVC_NAME"; busy
58 [ $RETVAL -eq 0 ] && ok || fail
59 [ "$out" ] && echo >&2 "$out"
61 # run config test and abort with nice message if failed
62 # (for actions checking status before action).
63 show "Checking %s configuration" "$SVC_NAME"; busy
64 configtest >/dev/null 2>&1
66 if [ $RETVAL -eq 0 ]; then
70 nls 'Configuration test failed. See details with %s "checkconfig"' $0
77 # Check if the service is already running?
78 if [ -f /var/lock/subsys/httpd ]; then
79 msg_already_running "$SVC_NAME"
83 [ "$1" -eq 0 ] || checkconfig
84 msg_starting "$SVC_NAME"
85 # remove ssl_scache on startup, otherwise httpd may go into
86 # infinite loop if there are db transaction logs laying around
87 rm -f /var/cache/httpd/*ssl_scache*
88 daemon --pidfile /var/run/httpd.pid /usr/sbin/httpd $CFG $HTTPD_OPTS
90 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
95 if [ ! -f /var/lock/subsys/httpd ]; then
96 msg_not_running "$SVC_NAME"
100 msg_stopping "$SVC_NAME"
101 killproc --pidfile /var/run/httpd.pid httpd
102 rm -f /var/lock/subsys/httpd /var/run/httpd.pid /var/run/httpd.loc* >/dev/null 2>&1
107 if [ ! -f /var/lock/subsys/httpd ]; then
108 msg_not_running "$SVC_NAME"
114 msg_reloading "$SVC_NAME"
116 /usr/sbin/httpd $CFG $HTTPD_OPTS -k graceful
118 [ $RETVAL -eq 0 ] && ok || fail
122 if [ ! -f /var/lock/subsys/httpd ]; then
123 msg_not_running "$SVC_NAME"
134 # See how we were called.
150 reload|force-reload|graceful|flush-logs)
153 checkconfig|configtest)
159 /usr/sbin/httpd $CFG $HTTPD_OPTS -S
162 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|graceful|configtest|status}"