• 设置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

  • 相关阅读:
    mate9进水黑屏维修
    无重复最长字串
    布偶猫
    移除失效的打开方式
    NAO机器人实验日常
    226. 翻转二叉树
    20.有效括号
    GraphX中的图构造器
    Spark读取Hive数据的方式
    GraphX中顶点和边的RDD操作
  • 原文地址:https://www.cnblogs.com/phplhs/p/4136133.html
Copyright © 2020-2023  润新知