zoukankan      html  css  js  c++  java
  • 设置nginx开机启动

      制作nginx开机启动脚本:

          vi /etc/init.d/nginx

    -------------------------------以下是脚本内容--------------------------------------

    #! /bin/sh
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: starts the nginx web server

    PATH=$PATH:/usr/local/nginx
    DESC="nginx daemon"
    NAME=nginx
    DAEMON=/usr/local/nginx/sbin/$NAME      //根据安装目录自行调整
    CONFIGFILE=/usr/local/nginx/conf/$NAME.conf  //根据安装目录自行调整
    PIDFILE=/usr/local/nginx/logs/$NAME.pid   //根据安装目录自行调整
    SCRIPTNAME=/etc/init.d/$NAME

    set -e
    [ -x "$DAEMON" ] || exit 0

    do_start() {
    $DAEMON -c $CONFIGFILE || echo -n "nginx already running"
    }

    do_stop() {
    kill -INT `cat $PIDFILE` || echo -n "nginx not running"
    }

    do_reload() {
    kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
    }

    case "$1" in
    start)
    echo -n "Starting $DESC: $NAME"
    do_start
    echo "."
    ;;
    stop)
    echo -n "Stopping $DESC: $NAME"
    do_stop
    echo "."
    ;;
    reload|graceful)
    echo -n "Reloading $DESC configuration..."
    do_reload
    echo "."
    ;;
    restart)
    echo -n "Restarting $DESC: $NAME"
    do_stop
    do_start
    echo "."
    ;;
    *)
    echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
    exit 3
    ;;
    esac

    exit 0

    ------------------------------------------------------------------------------------------

    编辑系统启动脚本文件:

      vi /etc/rc.local //此文件是开机系统自动执行的脚本文件

       添加 /etc/init.d/nginx start

  • 相关阅读:
    ACE反应器(Reactor)模式(3)
    ACE反应器(Reactor)模式(2)
    ACE反应器(Reactor)模式(1)
    ACE主动对象模式(2)
    ACE主动对象模式(1)
    ACE中UDP通信
    ACE中TCP通信
    从golang-gin-realworld-example-app项目学写httpapi (六)
    从golang-gin-realworld-example-app项目学写httpapi (五)
    从golang-gin-realworld-example-app项目学写httpapi (四)
  • 原文地址:https://www.cnblogs.com/phplhs/p/4136133.html
Copyright © 2011-2022 走看看