zoukankan      html  css  js  c++  java
  • nginx 服务脚本编写模板

    编写nginx服务脚本:脚本内容如下:
    
    [root@www ~]# cat /etc/init.d/nginx
    #!/bin/bash
    # nginx Startup script for the Nginx HTTP Server
    # chkconfig: - 85 15
    # pidfile: /usr/local/nginx1.10/logs/nginx.pid
    # config: /usr/local/nginx1.10/conf/nginx.conf
    nginxd=/usr/local/nginx1.10/sbin/nginx
    nginx_config=/usr/local/nginx1.10/conf/nginx.conf
    nginx_pid=/usr/local/nginx1.10/logs/nginx.pid
    RETVAL=0
    prog="nginx"
    # Source function library.
    . /etc/rc.d/init.d/functions
    # Start nginx daemons functions.
    start() {
    if [ -f $nginx_pid ] ; then
    echo "nginx already running...."
    exit 1
    fi
    echo -n "Starting $prog: "
       $nginxd -c ${nginx_config}
       RETVAL=$?
    [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
    }
    # Stop nginx daemons functions.
    stop() {
    echo -n "Stopping $prog: "
            $nginxd -s stop
            RETVAL=$?
    [ $RETVAL = 0 ] &&rm -f /var/lock/subsys/nginx
    }
    # reloadnginx service functions.
    reload() {
    echo -n "Reloading $prog: "
        $nginxd -s reload
    }
    # statusngnx service functions
    status() {
    if [ -f $nginx_pid ] ; then
    echo  "$prog is running"
    else
    echo  "$prog is stop"
    fi
    }
    case "$1" in
    start)
    start
            ;;
    stop)
    stop
            ;;
    reload)
    reload
            ;;
    restart)
    stop
    start
            ;;
    status)
    status
            ;;
    *)
    echo "Usage: $prog {start|stop|restart|reload|status}"
    exit 1
            ;;
    esac
    [root@www ~]# chmod +x /etc/init.d/nginx
    [root@www ~]# chkconfig --add nginx
    [root@www ~]# chkconfignginx on
    [root@www ~]# systemctl daemon-reload
  • 相关阅读:
    XAMPP安装过程中,出现的问题
    Javascript的数据类型和转换
    Vue组件之间的通信
    vue2.0在页面中自定义组件模块,以及页面与组件之间的数据传递
    本地起一个https服务器
    开发人员初始化操作
    添加环境变量
    公钥~gitlab~免密登录
    class继承随笔
    阿里云ECS随笔
  • 原文地址:https://www.cnblogs.com/netsa/p/7028034.html
Copyright © 2011-2022 走看看