Skip to content

Instantly share code, notes, and snippets.

@apisznasdin
Created July 13, 2015 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apisznasdin/966c236ed761d0578e54 to your computer and use it in GitHub Desktop.
Save apisznasdin/966c236ed761d0578e54 to your computer and use it in GitHub Desktop.
Apache2 rc init script
APACHE_HOME=/usr/local/apache2
CONF_FILE=${APACHE_HOME}/conf/httpd.conf
RUNDIR=/var/run/apache2
PIDFILE=${RUNDIR}/httpd.pid
if [ ! -f ${CONF_FILE} ]; then
exit 0
fi
if [ ! -d ${RUNDIR} ]; then
/usr/bin/mkdir -p -m 755 ${RUNDIR}
fi
case "$1" in
start|startssl|sslstart|start-SSL)
/bin/rm -f ${PIDFILE}
cmdtext="starting"
;;
restart)
cmdtext="restarting"
;;
stop)
cmdtext="stopping"
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
echo "httpd $cmdtext."
/bin/sh -c "${APACHE_HOME}/bin/apachectl $1" 2>&1 &
status=$?
if [ $status != 0 ]; then
echo "exit status $status"
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment