Nginx的系统启动服务脚本(shell)

vim /etc/init.d/nginx
#!/bin/bash
#chkconfig: - 99 22
#description: Nginx Server Control Script
PROG="/usr/local/nginx/sbin/nginx" #主程序路径
PIDF="/usr/cocal/nginx/logs/nginx.pid" #pid存放路径
case "$1" in
start)
$PROG
;;
stop)
kill -s QUIT $(cat $PIDF)
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PIDF)
;;
*)
echo "Usage:$0 {start|stop|restart|reload}"
exit 1
esac
exit 0
保存退出
chmod +x /etc/init.d/nginx
chkconfig --add nginx

posted @ 2017-12-20 19:38  Leonardo-li  阅读(425)  评论(0编辑  收藏  举报