nginx1.10.0启动脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx1.10.0启动脚本相关的知识,希望对你有一定的参考价值。

#!/bin/sh
#
# nginx Start up the nginx server daemon
#
# chkconfig: 2345 55 25
# Description: starts and stops the nginx web server
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: starts and stops the nginx web server
### END INIT INFO
# To install:
# copy this file to /etc/init.d/nginx
# shell> chkconfig --add nginx (RedHat)
# shell> update-rc.d -f nginx defaults (debian)
# To uninstall:
# shell> chkconfig --del nginx (RedHat)
# shell> update-rc.d -f nginx remove
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDDIR=/var/local/nginx/logs
PIDFILE=$PIDDIR/$NAME.pid
ULIMIT=10240
set -e
[ -x "$DAEMON" ] || exit 0

do_start() {
    echo "Starting $NAME ..."
    ulimit -SHn $ULIMIT
    
    $DAEMON -c $CONFIGFILE
}

do_stop() {
    echo "Shutting down $NAME ..."
    $DAEMON -s stop
}

do_reload() {
    echo "Reloading $NAME ..."
    $DAEMON -s reload
}

case "$1" in
start)
    [ ! -f "$PIDFILE" ] && do_start || echo "nginx already running"
    echo -e ".\ndone"
;;

stop)
    do_stop || echo "nginx not running"
    echo -e ".\ndone"
;;

reload)
    do_reload || echo "nginx not running"
    echo -e ".\ndone"
;;

*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload}" >&2
exit 1
;;

esac

exit 0

以上是关于nginx1.10.0启动脚本的主要内容,如果未能解决你的问题,请参考以下文章

CENTOS7开机自启动脚本

Linux下开机启动脚本程序

在Linux中如何将脚本做成系统服务开机自启动?

CentOS7 设置开机自启动脚本

启动Java应用的Shell脚本

linux开机自动启动脚本放在哪儿