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
完毕