• shell脚本一键安装nginx


    依赖包安装包放在一起, 直接执行这个脚本就行。

    #!/bin/bash
    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    #|                                            chenglee public nginx                                               |#
    #|                                            version: nginx-1.9.10                                               |#
    #|                                            version: openssl-1.1.0f                                             |#
    #|                                            version: pcre-8.40                                                  |#
    #|                                            version: zlib-1.2.11                                                |#
    #|                                               2018.12.04                                                       |# 
    #------------------------------------------------------------------------------------------------------------------#
    #|          Some people die at the age of 25 and don't bury themselves in the earth until they are 75             |#
    #------------------------------------------------------------------------------------------------------------------#
    #|                      $$$$ $$   $$ $$$$$$ $$    $$   $$$$$$          $$     $$$$$$ $$$$$$                       |#
    #|                     $$    $$   $$ $$     $$ $$ $$  $$               $$     $$     $$                           |#
    #|                    $$     $$$$$$$ $$$$$  $$  $$ $ $$  $$$$$$        $$     $$$$$  $$$$$                        |#
    #|                     $$    $$   $$ $$     $$   $ $  $$     $$        $$     $$     $$                           |#
    #|                      $$$$ $$   $$ $$$$$$ $$    $$   $$$$$ $$        $$$$$$ $$$$$$ $$$$$$                       |#
    #------------------------------------------------------------------------------------------------------------------#
    K_NGINX="nginx-1.9.10.tar.gz"
    K_PCRE="pcre-8.40.tar.gz"
    K_OPENSSL="openssl-1.1.0f.tar.gz"
    K_ZLIB="zlib-1.2.11.tar.gz"
    PRENAME="nginx"
    installpath=$(cd `dirname $0`; pwd)
    
    function environment(){
        echo "-----------------------------------------------------------------------"
        echo "------------------------  check gcc  ----------------------------------"
        echo "-----------------------------------------------------------------------"
        GCCBIN=`which gcc`
        GCCV=$(echo $GCCBIN | grep "gcc")
        if [[ "$GCCV" != "" ]]
        then
            echo "gcc was installed "
        else
            echo "install gcc"
            yum install gcc gcc-c++ -y >/dev/null 2>&1
        fi 
    }
    
    function initialize(){
        installpath=$(cd `dirname $0`; pwd)
        cd ${installpath}
        cd ${PRENAME}/lib/openssl* && OPENSSLPATH=`pwd`
        cd ${installpath}
        cd ${PRENAME}/lib/pcre* && PCREPATH=`pwd`
        cd ${installpath}
        cd ${PRENAME}/lib/zlib* && ZLIBPATH=`pwd`
        cd ${installpath}
    }
    
    function installssl(){
        echo "-----------------------------------------------------------------------"
        echo "----------------------  install openssl  ------------------------------"
        echo "-----------------------------------------------------------------------"
        mkdir -p logs ${PRENAME}/lib && touch logs/{openssl.log,pcre.log,zlib.log,nginx.log}
        #openss
        tar -zxvf ${K_OPENSSL} -C ${PRENAME}/lib >/dev/null 2>&1
        cd ${PRENAME}/lib/openssl* && OPENSSLPATH=`pwd`
        ./config --prefix=${OPENSSLPATH} >${installpath}/logs/openssl.log >/dev/null 2>&1
        if [[ $? -ne 0 ]]; then
            return 1
        else
            make && make install >${installpath}/logs/openssl.log
            if [[ $? -ne 0 ]]; then
                return 1
            fi
            return 0
        fi
    }
    function installpcre(){
        echo "-----------------------------------------------------------------------"
        echo "----------------------  install pcre  ---------------------------------"
        echo "-----------------------------------------------------------------------"
        #pcre
        cd ${installpath}
        tar -zxvf ${K_PCRE} -C ${PRENAME}/lib >/dev/null 2>&1
        cd ${PRENAME}/lib/pcre* && PCREPATH=`pwd`
        ./configure --prefix=${PCREPATH} >${installpath}/logs/pcre.log >/dev/null 2>&1
        if [[ $? -ne 0 ]]; then
            return 1
        else
            make && make install >${installpath}/logs/pcre.log
            if [[ $? -ne 0 ]]; then
                return 1
            fi
            return 0
        fi
    }
    function installzlib(){
        echo "-----------------------------------------------------------------------"
        echo "----------------------  install zlib  ---------------------------------"
        echo "-----------------------------------------------------------------------"
        #zlib
        cd ${installpath}
        tar -zxvf ${K_ZLIB} -C ${PRENAME}/lib >/dev/null 2>&1
        cd ${PRENAME}/lib/zlib* && ZLIBPATH=`pwd`
        ./configure --prefix=${ZLIBPATH} >${installpath}/logs/zlib.log >/dev/null 2>&1
        if [[ $? -ne 0 ]]; then
            return 1
        else
            make && make install >${installpath}/logs/zlib.log
            if [[ $? -ne 0 ]]; then
                return 1
            fi
            return 0
        fi
    }
    function installnginx(){
        echo "-----------------------------------------------------------------------"
        echo "----------------------  install nginx  --------------------------------"
        echo "-----------------------------------------------------------------------"
        #nginx
        cd ${installpath}
        initialize
        tar -zxvf ${K_NGINX} >/dev/null 2>&1
        cd nginx-* && NGINXPATH=`pwd`
        ./configure --prefix=${installpath}/${PRENAME} --with-pcre=${PCREPATH} --with-openssl=${OPENSSLPATH} --with-zlib=${ZLIBPATH}
        if [[ $? -ne 0 ]]; then
            return 1
        else
            make && make install >${installpath}/logs/nginx.log
            if [[ $? -ne 0 ]]; then
                return 1
            fi
            return 0
        fi
    }
    
    environment
    installssl
    installpcre
    installzlib
    installnginx
    
  • 相关阅读:
    【Repost】Comparision of B-Tree and LSM Tree
    字符串经典算法 Knuth-Morris-Pratt Boyer-Moore AC(Aho-Corasick)算法 后缀自动机
    【Leetcode 913】【Hard】Cat and Mouse 博弈论
    【转】初探计算机视觉的三个源头、兼谈人工智能
    MySQL--06(索引)
    MySQL--05(子查询&视图)
    MySQL--04(聚合函数&表连接查询)
    MySQL--03(增删改查&主键)
    MySQL--02
    MySQL--01
  • 原文地址:https://www.cnblogs.com/chenglee/p/10069172.html
Copyright © 2020-2023  润新知