一键安装nghttp2
python版本获取脚本
python_version.py,内容如下:
import sys
print (sys.version)
安装脚本
nghttp2_install.sh,内容如下:
#! /bin/bash
#author egypt
#date 2016.9.12
if [ ! -n "$PKG_CONFIG" ]
then
echo "export PKG_CONFIG=`which pkg-config`" >> ~/.bash_profile
source ~/.bash_profile
fi
if [ ! -n "$LD_LIBRARY_PATH" ]
then
echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.bash_profile
source ~/.bash_profile
fi
if [ ! -n "$PKG_CONFIG_PATH" ]
then
echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig" >> ~/.bash_profile
source ~/.bash_profile
fi
echo "----------------step 1----------------------"
if [ ! -f libtool-2.4.6.tar.gz ]
then
wget http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz
if [ $? -ne 0 ]
then
echo "download libtool-2.4.6.tar.gz fail"
exit 1
else
echo "download libtool-2.4.6.tar.gz success"
fi
fi
tar -xvf libtool-2.4.6.tar.gz
cd libtool-2.4.6
./configure --prefix=/usr/local/libtool-2.4.6
make
if [ $? -ne 0 ]
then
echo “install libtool-2.4.6 fail"
exit 1
else
echo “install lib tool-2.4.6 success"
fi
make install
cd ..
if [ -L /usr/bin/libtool ] || [ -f /usr/bin/libtool ]
then
mv /usr/bin/libtool /usr/bin/libtool.bak
fi
ln -s /usr/local/libtool-2.4.6/bin/libtool /usr/bin/libtool -f
if [ -L /usr/bin/libtoolize ] || [ -f /usr/bin/libtoolize ]
then
mv /usr/bin/libtoolize /usr/bin/libtoolize.bak
fi
ln -s /usr/local/libtool-2.4.6/bin/libtoolize /usr/bin/libtoolize -f
if [ -f /usr/share/aclocal/libtool.m4 ]
then
mv /usr/share/aclocal/libtool.m4 /usr/share/aclocal/libtool.m4.bak
fi
yes|cp /usr/local/libtool-2.4.6//share/aclocal/libtool.m4 /usr/share/aclocal
if [ -f /usr/share/aclocal/ltoptions.m4 ]
then
mv /usr/share/aclocal/ltoptions.m4 /usr/share/aclocal/ltoptions.m4.bak
fi
yes|cp /usr/local/libtool-2.4.6//share/aclocal/ltoptions.m4 /usr/share/aclocal
if [ -f /usr/share/aclocal/ltversion.m4 ]
then
mv /usr/share/aclocal/ltversion.m4 /usr/share/aclocal/ltversion.m4.bak
fi
yes|cp /usr/local/libtool-2.4.6//share/aclocal/ltversion.m4 /usr/share/aclocal
echo "----------------step 2----------------------"
if [ ! -f autoconf-2.69.tar.gz ]
then
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
if [ $? -ne 0 ]
then
echo "download autoconf-2.69.tar.gz fail"
exit 1
else
echo "download autoconf-2.69.tar.gz success"
fi
fi
tar -xvf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure --prefix=/usr/local/autoconf-2.69
make
if [ $? -ne 0 ]
then
echo "install autoconf-2.69.tar.gz fail"
exit 1
else
echo "install autoconf-2.69.tar.gz success"
fi
make install
cd ..
echo 'create soft link "ln -s/usr/local/autoconf-2.69/bin/autoconf /usr/bin/autoconf"'
if [ -L /usr/bin/autoconf ]
then
mv /usr/bin/autoconf /usr/bin/autoconf.bak
fi
ln -f -s /usr/local/autoconf-2.69/bin/autoconf /usr/bin/autoconf
if [ -L /usr/bin/autoheader ]
then
mv /usr/bin/autoheader /usr/bin/autoheader.bak
fi
ln -f -s /usr/local/autoconf-2.69/bin/autoheader /usr/bin/autoheader
if [ -L /usr/bin/autom4te ]
then
mv /usr/bin/autom4te /usr/bin/autom4te.bak
fi
ln -f -s /usr/local/autoconf-2.69/bin/autom4te /usr/bin/autom4te
if [ -L /usr/bin/autoreconf ]
then
mv /usr/bin/autoreconf /usr/bin/autoreconf.bak
fi
ln -f -s /usr/local/autoconf-2.69/bin/autoreconf /usr/bin/autoreconf
echo "----------------step 3----------------------"
if [ ! -f automake-1.15.tar.gz ]
then
wget http://ftp.gnu.org/gnu/automake/automake-1.15.tar.gz
if [ $? -ne 0 ]
then
echo "download automake-1.15.tar.gz fail"
exit 1
else
echo "download automake-1.15.tar.gz success"
fi
fi
tar -xvf automake-1.15.tar.gz
cd automake-1.15
./configure --prefix=/usr/local/automake-1.15
make
if [ $? -ne 0 ]
then
echo "install automake-1.15.tar.gz fail"
exit 1
else
echo "install automake-1.15.tar.gz success"
fi
make install
cd ..
if [ -f /usr/bin/automake ]
then
mv /usr/bin/automake /usr/bin/automake.bak
fi
ln -s /usr/local/automake-1.15/bin/automake /usr/bin/automake
if [ -f /usr/bin/aclocal ]
then
mv /usr/bin/aclocal /usr/bin/aclocal.bak
fi
ln -s /usr/local/automake-1.15/bin/aclocal /usr/bin/
dst_path=`aclocal --print-ac-dir`
yes|cp -rf /usr/local/libtool-2.4.6/share/aclocal/* $dst_path
echo "----------------step 4----------------------"
if [ ! -f libxml2-2.8.0.tar.gz ]
then
wget ftp://xmlsoft.org/libxml2/libxml2-2.8.0.tar.gz
if [ $? -ne 0 ]
then
echo "download libxml2-2.8.0.tar.gz fail"
exit 1
else
echo "download libxml2-2.8.0.tar.gz success"
fi
fi
tar -xvf libxml2-2.8.0.tar.gz
cd libxml2-2.8.0
# 出现/bin/rm: cannot remove`libtoolT': No such file or directory错误
# 解决办法
# 注释掉#$RM "$cfgfile"这行
sed -i "s/\$RM \"cfgfile\"/# \$RM \"cfgfile\"/g"
./configure --prefix=/usr/local/libxml-2.8.0
make -j 4
if [ $? -ne 0 ]
then
echo "install libxml2-2.8.0.tar.gz fail"
exit 1
else
echo "install libxml2-2.8.0.tar.gz success"
fi
make install
cd ..
yes|cp /usr/local/libxml-2.8.0/share/aclocal/libxml.m4 /usr/local/automake-1.15/share/aclocal
echo "export XML2_CONFIG=/usr/local/libxml-2.8.0/bin/xml2-config" >> ~/.bash_profile
source ~/.bash_profile
echo "----------------step 5----------------------"
if [ -f libev_4.22.orig.tar.gz ]
then
mv libev_4.22.orig.tar.gz libev-4.22.tar.gz
fi
if [ ! -f libev-4.22.tar.gz ]
then
wget http://dist.schmorp.de/libev/libev-4.22.tar.gz
if [ $? -ne 0 ]
then
echo "download libev-4.22.tar.gz fail"
exit 1
else
echo "download libev-4.22.tar.gz success"
fi
fi
tar -zxvf libev-4.22.tar.gz
cd libev-4.22
./configure
make
if [ $? -ne 0 ]
then
echo "install libev-4.22.tar.gz fail"
exit 1
else
echo "install libev-4.22.tar.gz success"
fi
make install
cd ..
echo "----------------step 6----------------------"
if [ ! -f openssl-OpenSSL_1_0_2g.tar.gz ]
then
wget https://codeload.github.com/openssl/openssl/tar.gz/OpenSSL_1_0_2g
if [ $? -ne 0 ]
then
echo "download openssl-OpenSSL_1_0_2g.tar.gz fail"
exit 1
else
echo "download openssl-OpenSSL_1_0_2g.tar.gz"
fi
fi
tar -xvf openssl-OpenSSL_1_0_2g.tar.gz
cd openssl-OpenSSL_1_0_2g
./config --prefix=/usr/local/openssl-OpenSSL_1_0_2g shared
make
if [ $? -ne 0 ]
then
echo "intall openssl-OpenSSL_1_0_2g.tar.gz fail"
else
echo "install openssl-OpenSSL_1_0_2g.tar.gz success"
fi
make install
cd ..
echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/openssl-OpenSSL_1_0_2g/lib/pkgconfig" >> ~/.bash_profile
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/openssl-OpenSSL_1_0_2g/lib" >> ~/.bash_profile
source ~/.bash_profile
echo "----------------step 7----------------------"
if [ ! -f master.zip ]
then
wget https://github.com/libevent/libevent/archive/master.zip
if [ $? -ne 0 ]
then
echo "download libevent-master.zip fail"
exit 1
else
echo "download libevent-master.zip success"
fi
fi
unzip master.zip
cd libevent-master
./autogen.sh
./configure --prefix=/usr/local/libevent
#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/libevent ./
make
if [ $? -ne 0 ]
then
echo "install libevent-master.zip fail"
exit 1
else
echo "install libevent-master.zip success"
fi
make install
cd ..
echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/libevent/lib/pkgconfig" >> ~/.bash_profile
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/libevent/lib" >> ~/.bash_profile
source ~/.bash_profile
echo "----------------step 8----------------------"
if [ ! -f spdylay-1.3.2.tar.gz ]
then
wget https://github.com/tatsuhiro-t/spdylay/releases/download/v1.3.2/spdylay-1.3.2.tar.gz
if [ $? -ne 0 ]
then
echo "download spdylay-1.3.2.tar.gz fail"
exit 1
else
echo "download spdylay-1.3.2.tar.gz success"
fi
fi
tar -xvf spdylay-1.3.2.tar.gz
cd spdylay-1.3.2
#解决MAX_INT64未定义的问题
sed -i "/#include \"shrpx.h\"/i\#define __STDC_LIMIT_MACROS" ./src/shrpx.cc
autoreconf -i -I/usr/share/aclocal/
automake
autoconf
./configure --prefix=/usr/local/spdylay-1.3.2
make -j 4
if [ $? -ne 0 ]
then
echo "install spdylay-1.3.2.tar.gz fail"
exit 1
else
echo "install spdylay-1.3.2.tar.gz success"
fi
make install
cd ..
echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/spdylay-1.3.2/lib/pkgconfig" >> ~/.bash_profile
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/spdylay-1.3.2/lib" >> ~/.bash_profile
source ~/.bash_profile
echo "----------------step 9----------------------"
if [ ! -f jemalloc-4.2.0.tar.bz2 ]
then
wget https://github.com/jemalloc/jemalloc/releases/download/4.2.0/jemalloc-4.2.0.tar.bz2
if [ $? -ne 0 ]
then
echo "download jemalloc-4.2.0.tar.bz2 fail"
exit 1
else
echo "download jemalloc-4.2.0.tar.bz2 success"
fi
fi
tar -xvf jemalloc-4.2.0.tar.bz2
cd jemalloc-4.2.0
./configure
make
if [ $? -ne 0 ]
then
echo "install jemalloc-4.2.0.tar.bz2 fail"
exit 1
else
echo "install jemalloc-4.2.0.tar.bz2 success"
fi
make install
cd ..
echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig" >> ~/.bash_profile
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib" >> ~/.bash_profile
source ~/.bash_profile
echo "----------------step 10----------------------"
yum install boost boost-develboost-doc
#if [ -f boost_1_61_0.tar.gz ]
#then
#wget http://101.44.1.118/files/9180000004F0A7F9/pilotfiber.dl.sourceforge.net/project/boost/boost/1.61.0/boost_1_61_0.tar.gz
#if [ $? -ne 0 ]
#then
#echo "download boost_1_61_0.tar.gz fail"
#exit 1
#else
#echo "download boost_1_61_0.tar.gz success"
#fi
#fi
#tar -xvf boost_1_61_0.tar.gz
#cd boost_1_61_0
#获取bjam
#./bootstrap.sh
#./bjam stage --with-thread --with-date_time toolset=gcc --build-type=minimal variant=release link=shared threading=multi --with-system
#yes|cp boost -r /usr/include
#mkdir -p /usr/lib/boost -f && yes|cp stage/lib/libboost_* /usr/lib/boost -f && ldconfig
#cd ..
if [ $? -ne 0 ]
then
echo "install boost* fail"
exit 1
else
echo "install boost* success"
fi
echo "----------------step 11----------------------"
if [ ! -f gmp-6.1.1.tar.bz2 ]
then
wget https://gmplib.org/download/gmp/gmp-6.1.1.tar.bz2
if [ $? -ne 0 ]
then
echo "download gmp-6.1.1.tar.bz2 fail"
exit 1
else
echo "download gmp-6.1.1.tar.bz2 success"
fi
fi
tar -xvf gmp-6.1.1.tar.bz2
cd gmp-6.1.1
./configure --prefix=/usr/local/gmp-6.1.1
make -j 4
if [ $? -ne 0 ]
then
echo "install gmp-6.1.1.tar.bz2 fail"
exit 1
else
echo "install gmp-6.1.1.tar.bz2 success"
fi
make install
cd ..
echo "`pwd`"
if [ ! -f mpfr-3.1.4.tar.bz2 ]
then
wget http://www.mpfr.org/mpfr-current/mpfr-3.1.4.tar.bz2
if [ $? -ne 0 ]
then
echo "download mpfr-3.1.4.tar.gz2 fail"
exit 1
else
echo "download mpfr-3.1.4.tar.gz2 success"
fi
fi
tar -xvf mpfr-3.1.4.tar.bz2
cd mpfr-3.1.4
./configure --prefix=/usr/local/mpfr-3.1.4 --with-gmp=/usr/local/gmp-6.1.1/
make -j 4
if [ $? -ne 0 ]
then
echo "install mpfr-3.1.4.tar.bz2 fail"
exit 1
else
echo "install mpfr-3.1.4.tar.bz2 success"
fi
make install
cd ..
if [ ! -f mpc-0.8.2.tar.gz ]
then
wget http://www.multiprecision.org/mpc/download/mpc-0.8.2.tar.gz
if [ $? -ne 0 ]
then
echo "download mpc-0.8.2.tar.gz fail"
exit 1
else
echo "download mpc-0.8.2.tar.gz success"
fi
fi
tar -xvf mpc-0.8.2.tar.gz
cd mpc-0.8.2
./configure --prefix=/usr/local/mpc-0.8.2 --with-gmp=/usr/local/gmp-6.1.1/ --with-mpfr=/usr/local/mpfr-3.1.4/
make -j 4
if [ $? -ne 0 ]
then
echo "install mpc-0.8.2.tar.gz fail"
exit 1
else
echo "install mpc-0.8.2.tar.gz success"
fi
make install
cd ..
echo "set environment variable \$LD_LIBRARY_PATH....."
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/gmp-6.1.1/lib:/usr/local/mpfr-3.1.4/lib:/usr/local/mpc-0.8.2/lib" >> /root/.bash_profile
source ~/.bash_profile
is_pass=`echo $LD_LIBRARY_PATH | awk 'BEGIN {has_gmp=0;has_mpfr=0;has_mpc=0} $0 ~/gmp-6.1.1/{has_gmp=1} $0 ~ /mpfr-3.1.4/ {has_mpfr=1} $0 ~/mpc-0.8.2/{has_mpc=1}END{if(has_gmp == 1 && has_mpfr == 1 && has_mpc == 1){ print 1 }else{ print 0 } } '`
if [ $is_pass -eq 1 ]
then
echo "echo \$LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
else
echo "set environment variable \$LD_LIBRARY_PATH fail"
exit 1
fi
if [ -f gcc-4.9.0.tar.bz2 ]
then
mv gcc-4.9.0.tar.bz2 gcc-4.9.0.tar.gz
fi
if [ ! -f gcc-4.9.0.tar.gz ]
then
wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.9.0/gcc-4.9.0.tar.gz
if [ $? -ne 0 ]
then
echo "download gcc-4.9.0.tar.gz fail"
exit 1
else
echo "download gcc-4.9.0.tar.gz success"
fi
fi
tar -xvf gcc-4.9.0.tar.gz
cd gcc-4.9.0
./configure --prefix=/usr/local/gcc-4.9.0 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp-6.1.1/ --with-mpfr=/usr/local/mpfr-3.1.4/ --with-mpc=/usr/local/mpc-0.8.2/
make -j 4
if [ $? -ne 0 ]
then
echo "install gcc-4.9.0.tar.gz fail"
exit 1
else
echo "install gcc-4.9.0.tar.gz success"
fi
make install
cd ..
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/gcc-4.9.0/lib" >> /root/.bash_profile
source ~/.bash_profile
if [ -L /usr/bin/gcc ]
then
mv /usr/bin/gcc /usr/bin/gcc.bak
fi
ln -s /usr/local/gcc-4.9.0/bin/gcc /usr/bin/gcc -f
if [ -L /usr/bin/cc ]
then
mv /usr/bin/cc /usr/bin/cc.bak
fi
ln -s /usr/local/gcc-4.9.0/bin/gcc /usr/bin/cc -f
if [ -L /usr/bin/g++ ]
then
mv /usr/bin/g++ /usr/bin/g++.bak
fi
ln -s /usr/local/gcc-4.9.0/bin/g++ /usr/bin/g++ -f
if [ -L /usr/bin/c++ ]
then
mv /usr/bin/c++ /usr/bin/c++.bak
fi
ln -s /usr/local/gcc-4.9.0/bin/g++ /usr/bin/c++ -f
yes|cp -f /usr/local/gcc-4.9.0/lib64/* /usr/lib64
echo "----------------step 12----------------------"
version=`python python_version.py | awk '{if (NR == 1){print $0}}' | awk '{print $1}'`
if [[ $version < "2.7" ]]
then
if [ ! -f Python-2.7.12.tgz ]
then
wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz
if [ $? -ne 0 ]
then
echo "download Python-2.7.12.tgz fail"
exit 1
else
echo "download Python-2.7.12.tgz success"
fi
tar -xvf Python-2.7.12.tgz
cd Python-2.7.12
./configure --prefix=/usr/local/python-2.7.12
make
if [ $? -ne 0 ]
then
echo "install Pythion-2.7.12.tgz fail"
exit 1
else
echo "install Python-2.7.12.tgz success"
fi
make install
cd ..
if [ -f /usr/bin/python ] || [ -L /usr/bin/python ]
then
mv /usr/bin/python /usr/bin/python.bak
prefix=${version%.*}
sed -i "s/#\!\/usr\/bin\/python/#\!\/usr\/bin\/python$prefix/g" /usr/bin/yum
fi
ln -s /usr/local/python-2.7.12/bin/python /usr/bin/python -f
fi
fi
echo "----------------step 13----------------------"
if [ ! -f nghttp2-master.zip ]
then
wget https://github.com/nghttp2/nghttp2/archive/master.zip
if [ $? -ne 0 ]
then
echo "download nghttp2 fail"
exit 1
else
echo "download nghttp2 success"
mv master.zip nghttp2-master.zip
fi
fi
unzip nghttp2-master.zip
cd nghttp2-master
autoreconf -i -I /usr/share/aclocal/
automake
autoconf
./configure --prefix=/usr/local/nghttp2
make
if [ $? -ne 0 ]
then
echo "install nghttp2-master.zip fail"
exit 1
else
echo "install nghttp2-master.zip success"
fi
make install
cd ..
echo "------------------------------install finish------------------------------"