nginx init script - Fedora 8, but easily adaptable
Posted
in Bryan's Blog
at 09:41AM on 04/15/2008
Here's an init script I just wrote for nginx on my fedora 8 box. It should be easy enough to modify for your own systems.
#!/bin/sh
# Start/Stop nginx - Fedora Core 8
# Created 4/15/08 by bryan thompson - http://www.skippidydoo.com
PATH= "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin: /usr/local/mysql/bin:/opt/local/bin"
export PATH
nginx=/usr/sbin/nginx
nginx_pid=/var/run/nginx.pid
case "$1" in
start)
echo "Starting nginx "
if [ -f $nginx_pid ]
then
echo "nginx is already running"
else
if [ -x $nginx ]
then
$nginx
fi
echo "nginx started"
fi
;;
stop)
echo "Stopping nginx"
if [ -f $nginx_pid ]
then
kill `cat $nginx_pid`
echo "nginx stopped"
else
echo "nginx is not running"
fi
;;
restart)
echo "Restarting nginx"
if [ -f $nginx_pid ]
then
kill -HUP `cat $nginx_pid`
else
echo "nginx is not running, starting it now"
$nginx
fi
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
or download the script here.
Comments