编译安装pcre2-10.39 zlib-1.3.1 openssl-3.0.13

#!/bin/bash
# auth:chenjf
# func:install nginx standalone
# version:v2.0
# sys:CentOS Linux release 7.9.2009(Core)
# installer version:pcre2-10.39  zlib-1.3.1  openssl-3.0.13
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
##要用root安装
[ $(id -u) -gt 0 ] && echo "please use root to execute the script!" && exit 1
path=$(cd $(dirname $0); pwd)

baktime=$(date +'%Y%m%d%H%M')
pcre_pkg=pcre2-10.39.tar.gz
zlib_pkg=zlib-1.3.1.tar.gz
openssl_pkg=openssl-3.0.13.tar.gz

pcre_dir=$(basename "$pcre_pkg" .tar.gz)
zlib_dir=$(basename "$zlib_pkg" .tar.gz)
openssl_dir=$(basename "$openssl_pkg" .tar.gz)

openssl_home=/usr/local/openssl

##用yum安装依赖包
yum repolist
yum -y install gcc gcc-c++ make automake perl-ExtUtils-MakeMaker perl-IPC-Cmd
check_xxx_home(){
    read -n3 -p "$xxx_home already exists,Do you want to delete and reinstall it? please set yes or no [Y/N][y/n]?" aaa
	case $aaa in
Y|y|yes)
           sudo rm -rf $xxx_home
		   echo "$xxx_home remove successful ";;
N|n|no)
           echo "ok,bye bye~~"
		   exit 0;;
*)
    echo "answer yes or no [Y/N][y/n] ,please.."
        check_xxx_home;;
esac
}

install_pcre(){
sudo tar -zxf $path/$pcre_pkg -C $path/
cd $path/$pcre_dir
./configure --enable-utf8 
sudo make
sudo make install 
echo "$pcre_dir install successfully!!!"
}


install_zlib(){
sudo tar -zxf $path/$zlib_pkg -C $path/
cd $path/$zlib_dir
./configure  
sudo make
sudo make install 
echo "$zlib_dir install successfully!!!"
}

install_openssl(){
mv  ${openssl_home}  ${openssl_home}_$baktime
tar -zxf $path/$openssl_pkg -C $path/
cd $path/$openssl_dir
./config  --prefix=$openssl_home --openssldir=$openssl_home shared zlib
#./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl shared zlib
make -j4
make install
#make && make install


\cp -a $openssl_home/lib64/libcrypto.so.3 $openssl_home/lib64/libssl.so.3  /usr/lib/

mv /usr/include/openssl /usr/include/openssl_$baktime
ln -sv $openssl_home/include/openssl /usr/include/openssl

mv /usr/bin/openssl /usr/bin/openssl_$baktime
ln -sf $openssl_home/bin/openssl /usr/bin/openssl

mv /etc/ld.so.conf.d/openssl.conf  /etc/ld.so.conf.d/openssl.conf_$baktime
egrep "$openssl_home" /etc/ld.so.conf  >& /dev/null
if [ $? -ne 0 ];then
    echo "$openssl_home/lib64" >> /etc/ld.so.conf
fi
egrep "/usr/local/lib" /etc/ld.so.conf  >& /dev/null
if [ $? -ne 0 ];then
    echo "/usr/local/lib" >> /etc/ld.so.conf
fi


ldconfig -v

echo "export OPENSSL_PATH=$openssl_home/bin" >> /etc/profile  
echo "export PATH=\$OPENSSL_PATH:\$PATH" >> /etc/profile      
echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$openssl_home/lib64" >> /etc/profile  
source /etc/profile 

openssl version
echo "$openssl_dir install successfully!!!"
}


install_pcre
install_zlib

if [ ! -d $openssl_home ];then
	echo "openssl_home does not exist,start to install........"
	install_openssl

else
    xxx_home=$openssl_home
    check_xxx_home
	install_openssl
fi

posted @ 2024-05-23 18:27  海yo  阅读(76)  评论(0编辑  收藏  举报