#!/bin/sh HTTPD=/usr/sbin/apache2 dir=`dirname $0` ROOT=$dir/httpd DOC_ROOT=$PWD PID_FILE="$ROOT/httpd.pid" PORT=8234 usage() { me=`basename $0` echo "$me: runs a local instance of apache (on port $PORT)" echo "Usage: $me - the usual" echo " $me log cat the log file" } run_httpd() { $HTTPD -d "$ROOT" -f etc/httpd.conf \ -C "Listen $PORT" \ -C "PidFile $PID_FILE" \ -C "DocumentRoot $DOC_ROOT" \ "$@" } case "$1" in start) shift; run_httpd "$@";; stop) run_httpd -k stop;; restart) "$0" stop sleep 1 "$0" start ;; reload) kill -HUP `cat "$PID_FILE"`;; status) if [ -f "$PID_FILE" ]; then ps `cat "$PID_FILE"` else echo "Not running" fi ;; log) cat "$ROOT/logs/error_log";; *) usage; exit 1;; esac