码迷,mamicode.com
首页 > 其他好文 > 详细

nginx各版本全自动编译安装脚本

时间:2019-11-08 10:47:47      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:Stub   系统   http   nload   config   txt   load   eal   user   

#!/bin/bash

#作者:星云法师(头条号:西西图图---专注美食领域的研究)

#环境:centos7,如果是其它的系统可以相应做调整。
#--------选择安装方式,网络晚装还是本地安装--------------
read -p "Install nginx from internet or localpacke?answer i or l:" installway
installways=`echo $installway| tr [a-z] [A-Z]`
read -p "Install some need tools(Y/N):" needpack
needpacks=`echo $needpack| tr [a-z] [A-Z]`

#----是否要配置安装环境---------------------------
if [ "$needpacks" == "Y" ];then
    cd /etc/yum.repos.d
    mkdir -p /etc/yum.repo.bak
    mv /etc/yum.repos.d/* /etc/yum.repo.bak
    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    yum clean all
    yum -y install openssh-clients wget gcc gcc-c++ install zlib zlib-devel openssl openssl-devel pcre-devel
elif [ "$needpacks" != "Y" ]&&[ "$needpacks" != "N" ];then
    echo "Input error!"
    exit 1
fi

#-----网络实际安装---------------------
if [ "$installways" == "I" ];then
    cd /tmp
    curl http://nginx.org/download/|awk -F‘"‘ ‘{print $2}‘|grep "nginx"|grep "tar"|awk -F‘.tar‘ ‘{print $1}‘ >/tmp/nginxtmp.txt
    sort /tmp/nginxtmp.txt|uniq

    #-------选择安装版本
    read -p "which version you want to install(input all you see):" version
    wget http://nginx.org/download/$version".tar.gz"
    tar xf $version".tar.gz"
        if [ $? -eq 0 ];then
            cd $version/
            groupadd nginx
            useradd nginx -g nginx -s /sbin/nologin -M
            ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module
            if [ $? -eq 0 ];then
                make && make install
                if [ $? -eq 0 ];then
                    echo "the bin in /usr/local/nginx/sbin/"
                fi
            fi
        fi

#------本地安装--------------------
elif [ "$installways" == "L" ];then

    #-----安装包来源主机---------------
    read -p "which ip your nginx packge from:" fromip

    #-----安装包在远程主机的路径---------------
    read -p "which path your packge in:" path

    #-----安装包版本,要全称--------------------
    read -p "which version your packge is(all name:nginx-1.14.2):" lversion

    if [ "$fromip" != "" ]&&[ "$path" != "" ];then
        destpath=$fromip:$path$lversion
        scp root@$destpath /usr/local
        cd /usr/local
        tar xf $lversion".tar.gz"
        if [ $? -eq 0 ];then
            cd $lversion/
            groupadd nginx
            useradd nginx -g nginx -s /sbin/nologin -M
            ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module
            if [ $? -eq 0 ];then
                make && make install
                if [ $? -eq 0 ];then
                    echo "the bin in /usr/local/nginx/sbin/"
                fi
            fi
        fi
    fi
elif [ "$installways" != "I" ]&&[ "$installways" != "L" ];then
    echo "Input error!";exit 1
fi

nginx各版本全自动编译安装脚本

标签:Stub   系统   http   nload   config   txt   load   eal   user   

原文地址:https://www.cnblogs.com/xingyunfashi/p/11818623.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!