• shell脚本自动安装nginx


    写一脚本,实现对nginx的自动化下载,安装,启动,停止

    #!/bin/sh

    ###nginx install shell

    SOFT_PATH=/data/soft
    NGINX_FILE=nginx-1.14.2.tar.gz
    DOWN_PATH=http://nginx.org/download/

    if [ $# -ne 1 ];then

    echo "USAAGE:$0{download or start or install or stop}"

    exit 0

    fi

    if [ $UID -ne 0 ];then
    echo this script must use administrator or root user.please exit!
    sleep 2
    exit 1
    fi

    if [ ! -d $SOFT_PATH ];then
    mkdir -p $SOFT_PATH
    mkdir -p /application/nginx1.14.2
    fi

    download()
    {
    cd $SOFT_PATH;wget $DOWN_PATH/$SOFT_FILE
    }

    install()
    {
    yum install -y pcre pcre-devel openssl openssl-devel
    cd $SOFT_PATH;tar xf $NGINX_FILE;cd nginx-1.14.2/ && ./configure --with-http_stub_status_module --with-http_ssl_module --prefix=/application/nginx1.14.2
    [ $? -eq 0 ] && make && make install
    ln -s /application/nginx1.14.2/ /application/nginx
    }

    start()
    {
    `netstat -lntp|grep 80`[ $? -ne 0 ] && /application/nginx/sbin/nginx
    }

    stop()
    {
    ps -ef|grep nginx|grep -v grep|awk '{print $2}'|xargs kill -9
    }

    case $1 in
    download)
    download
    ;;

    install)

    install

    ;;

    start)
    start
    ;;
    stop)
    stop
    ;;
    *)
    echo "USAAGE:$0{download or start or install or stop}"
    exit
    esac

  • 相关阅读:
    Form 中调用指定请求并给定默认参数
    OAF 汇总行的做法
    EBS 开发常用SQL
    EBS 中常用的配置文件及说明
    OAF 常见概念介绍
    OAF 多语言的实现
    OAF 个性化基础
    OAF 开发前置配置
    条款20 STL函数对象
    条款19 command 模式与好莱坞法则
  • 原文地址:https://www.cnblogs.com/liuhui-xzz/p/10317586.html
Copyright © 2020-2023  润新知