Nginx安装脚本

#!/usr/bin/env bash
echo "|------------------------ CHECK GCC--------------------------|"
GCCBIN=`which gcc`
GCCV=$(echo $GCCBIN | grep "gcc")
if [ "$GCCV" != "" ]; then
    echo "gcc was installed "
else
    echo "install gcc"
    yum install -y gcc
    yum install -y gcc-c++
    if [ $? -ne 0 ]; then
      echo "install gcc failed"
      exit 1
    fi
fi
localPath=`pwd`
installPath="/usr/local"
K_NGINX="nginx-1.8.0.tar.gz"
K_PCRE="pcre-8.33.tar.gz"
K_OPENSSL="openssl-1.0.1j.tar.gz"
K_ZLIB="zlib-1.2.11.tar.gz"

echo "-----------------------------------PCRE-------------------------"
echo
isExist=`ls | grep $K_PCRE`
if [ "$isExist" != "" ]; then
    echo "------------------Offline package of ${K_PCRE} found-------------------------"
    echo "-------------------${K_PCRE} is unzipping-----------------------------------"
    tar -zxvf ${K_PCRE} -C ${installPath}
else
    echo "------------------Offline package of ${K_PCRE} not found--------------------------------------"
    echo "------------------online package of ${K_PCRE} is downloading--------------------------------------"
    wget http://ftp.pcre.org/pub/pcre/${K_PCRE}
    echo "-------------------online package of ${K_PCRE} is unzipping-----------------------------------"
    tar -zxvf ${K_PCRE} -C ${installPath}
fi
 echo "-----------------------installing PCRE-----------------------------------"
cd ${installPath}/pcre-*
./configure
make && make install
if [ $? -ne 0 ]; then
   echo "-----------------------install PCRE failed-----------------------------------"
   exit 1
fi


cd ${localPath}
echo "-----------------------install PCRE success-----------------------------------"

echo "-----------------------------------SSL-------------------------"
echo
isExist=`ls | grep $K_OPENSSL`
if [ "$isExist" != "" ]; then
    echo "------------------Offline package of ${K_OPENSSL} found-------------------------"
    echo "-------------------${K_OPENSSL} is unzipping-----------------------------------"
    tar -zxvf ${K_OPENSSL} -C ${installPath}
else
    echo "------------------Offline package of ${K_OPENSSL} not found--------------------------------------"
    echo "------------------online package of ${K_OPENSSL} is downloading--------------------------------------"
    wget http://www.openssl.org/source/${K_OPENSSL}
    echo "-------------------online package of ${K_OPENSSL} is unzipping-----------------------------------"
    tar -zxvf ${K_OPENSSL} -C ${installPath}
fi
 echo "-----------------------installing openssl-----------------------------------"
cd ${installPath}/openssl-*
./config
make && make install
if [ $? -ne 0 ]; then
   echo "-----------------------install openssl failed-----------------------------------"
   exit 1
fi

echo "-----------------------install openssl sucess-----------------------------------"
cd ${localPath}


echo "-----------------------------------zlib-------------------------"
echo
isExist=`ls | grep $K_ZLIB`
if [ "$isExist" != "" ]; then
    echo "------------------Offline package of ${K_ZLIB} found-------------------------"
    echo "-------------------${K_ZLIB} is unzipping-----------------------------------"
    tar -zxvf ${K_ZLIB} -C ${installPath}
else
    echo "------------------Offline package of ${K_ZLIB} not found--------------------------------------"
    echo "------------------online package of ${K_ZLIB} is downloading--------------------------------------"
    wget http://zlib.net/${K_ZLIB}
    echo "-------------------online package of ${K_ZLIB} is unzipping-----------------------------------"
    tar -zxvf ${K_ZLIB} -C ${installPath}
fi
echo "-----------------------installing zlib-----------------------------------"
cd ${installPath}/zlib-*
./configure
make && make install
if [ $? -ne 0 ]; then
   echo "-----------------------install Zlib failed-----------------------------------"
   exit 1
fi

echo "-----------------------install zlib success-----------------------------------"
cd ${localPath}

echo "-----------------------------------nginx-------------------------"
echo
isExist=`ls | grep $K_NGINX`
if [ "$isExist" != "" ]; then
    echo "------------------Offline package of ${K_NGINX} found-------------------------"
    echo "-------------------${K_NGINX} is unzipping-----------------------------------"
    tar -zxvf ${K_NGINX} -C ${installPath}
else
    echo "------------------Offline package of ${K_NGINX} not found--------------------------------------"
    echo "------------------online package of ${K_NGINX} is downloading--------------------------------------"
    wget http://nginx.org/download/${K_NGINX}
    echo "-------------------online package of ${K_NGINX} is unzipping-----------------------------------"
    tar -zxvf ${K_NGINX} -C ${installPath}
fi
 echo "-----------------------installing nginx-----------------------------------"
cd ${installPath}/nginx-*
./configure
make && make install
if [ $? -ne 0 ]; then
   echo "-----------------------install nginx failed-----------------------------------"
   exit 1
fi
 echo "-----------------------install nginx success-----------------------------------"

安装包

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值