#!/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-----------------------------------"
安装包