#!/bin/sh # description: start/stop the Apache httpd Webserver # # default: S/K10 0/K10 1/K10 2/S90 # # Copyright 2000-2004 The Apache Software Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # # Apache control script designed to allow an easy command line interface # to controlling Apache. Written by Marc Slemko, 1997/08/23 # # The exit codes returned are: # XXX this doc is no longer correct now that the interesting # XXX functions are handled by httpd # 0 - operation completed successfully # 1 - # 2 - usage error # 3 - httpd could not be started # 4 - httpd could not be stopped # 5 - httpd could not be started during a restart # 6 - httpd could not be restarted during a restart # 7 - httpd could not be restarted during a graceful restart # 8 - configuration syntax error # # When multiple arguments are given, only the error from the _last_ # one is reported. Run "apachectl help" for usage info # ARGV="$@" # # |||||||||||||||||||| START CONFIGURATION SECTION |||||||||||||||||||| # -------------------- -------------------- # # the path to your httpd binary, including options if necessary HTTPD="@CLIENT_BASEDIR@/apache2/bin/httpd -d @CLIENT_BASEDIR@/apache2" # The config base directory CONFDIR="@CLIENT_BASEDIR@/apache2/conf" # pick up any necessary environment variables if test -f @CLIENT_BASEDIR@/apache2/bin/envvars; then . @CLIENT_BASEDIR@/apache2/bin/envvars fi # # a command that outputs a formatted text version of the HTML at the # url given on the command line. Designed for lynx, however other # programs may work. LYNX="lynx -dump" # # the URL to your server's mod_status status page. If you do not # have one, then status and fullstatus will not work. STATUSURL="http://localhost:80/server-status" # # Set this variable to a command that increases the maximum # number of file descriptors allowed per child process. This is # critical for configurations that use many file descriptors, # such as mass vhosting, or a multithreaded server. ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`" # -------------------- -------------------- # |||||||||||||||||||| END CONFIGURATION SECTION |||||||||||||||||||| # Set the maximum number of file descriptors allowed per child process. if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then $ULIMIT_MAX_FILES fi ERROR=0 if [ "x$ARGV" = "x" ] ; then ARGV="-h" fi case $ARGV in start) pgrep -f $HTTPD >/dev/null 2>&1 if [ $? -eq 1 ]; then # no apache is running - check and remove pidfile if [ -r ${CONFDIR}/httpd.conf ]; then PIDFILE=`egrep '^PidFile' ${CONFDIR}/httpd.conf | cut -f2 -d\ ` fi if [ -z "$PIDFILE" -a -r "${CONFDIR}/extra/mpm.conf" ]; then PIDFILE=`egrep '^PidFile' ${CONFDIR}/extra/mpm.conf | cut -f2 -d\ ` fi if [ -n "$PIDFILE" -a -r "$PIDFILE" ]; then # probably left over after system crash rm -f $PIDFILE 2>/dev/null fi fi echo "Starting apache2 server ..." $HTTPD -k $ARGV ERROR=$? ;; stop|restart|graceful|graceful-stop) X="" case $ARGV in stop) X="Stopping" ;; restart) X="Restarting" ;; graceful) X="Restarting gracefully" ;; graceful-stop) X="Stopping gracefully" ;; esac echo "$X apache2 server ..." $HTTPD -k $ARGV ERROR=$? ;; configtest) echo "Testing apache2 server configuration ..." $HTTPD -t ERROR=$? ;; status) $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } ' ;; fullstatus) $LYNX $STATUSURL ;; modules) $HTTPD -M ;; *) echo "Usage: $0 {start|restart|graceful|stop|graceful-stop|status|fullstatus|modules|configtest}" exit 1 esac if [ $ERROR -ne 0 ]; then echo "failed." else echo "done." fi exit $ERROR