打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
linux 开机自启动 nginx

if [ -z $1 ]

then

    echo "Usage: $0 {start|stop|reload|restart|status}"

    exit 1

fi

#service name for nginx

SNAME=nginx

#nginx home dir

NGINX_HOME=/usr/local/nginx

PID=$NGINX_HOME/logs/nginx.pid

#nginx running port

NGINX_PORT='netstat -anp|grep -w 80|grep LISTEN|grep -v TIME_WAIT|wc -l'

#the full path of daemon

NGINX_PROG=$NGINX_HOME/sbin/nginx

#start function

start(){

#check the daemon status first

if [ $NGINX_PORT -ne 0 ]

then

    echo "WARN: $SNAME is already started"

    exit 0;

else

    $NGINX_PROG

    echo "starting $SNAME .....................done"

    exit 0;

fi

}

#stop function

stop(){

    if [ $NGINX_PORT = 0 ]

    then

        echo "WARN: $SNAME has been stopped"

    else

        $NGINX_PROG -s quit

        echo "stopping $SNAME..........................done"

    fi

}

#reload function

restart(){

    if [ -f $PID ]

    then

        $NGINX_PROG -s reload

        echo "restart $SNAME .......................done"

    else

        echo "$PID is not exist!"

        $NGINX_PROG

        echo "start $SNAME .........................  done"

        fi

}

status(){

    if [ $NGINX_PORT = 0 ]

    then

        echo "$SNAME has already stopped!"

    else

        echo "$SNAME is running ok!"

    fi

}

case "$1" in

start)

    start

    ;;

stop)

    stop

    ;;

reload|restart)

    restart

    ;;

status)

    status

    ;;

*)

    echo "usage: $0 {start|stop|reload|restart|status}"

    exit 1

esac


....

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
nginx设置为系统服务
服务器上的Nginx和PHP都是源码编译安装的(转)--Nginx和PHP启动脚本
使用uWSGI+Nginx+Supervisor部署管理Django应用程序
Linux下的Nginx安装(开机自启动)
Apache启动脚本
CentOS 7 Nginx 控制脚本「更新」
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服