nginx添加系统服务(start|stop|restart|reload)

nginx添加系统服务


1、编写脚本,名为nginx

#vim /etc/init.d/nginx

#!/bin/bash
#chkconfig: - 99 20
#description: Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.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

:x  --保存退出

[root@example ~]#chmod +x /etc/init.d/nginx 

[root@example ~]# chkconfig --add nginx

3、nginx启动、停止、无间断服务重启

[root@example ~]# service nginx start

[root@example ~]# service nginx stop

[root@example ~]# service nginx reload

完毕


能够潇洒恣意的活,必然背负孤独寂寞的伤! Blog: http://www.cnblogs.com/chaichuan/
原文地址:https://www.cnblogs.com/chaichuan/p/3801622.html