1. 安装gcc等编译器、依赖库
yum install gcc gcc-c++ zlib zlib-devel bzip2-devel xz-devel libffi-devel make -y
2. 安装libressl
wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.7.0.tar.gz --no-check-certificate
tar zxvf libressl-3.7.0.tar.gz
cd libressl-3.7.0
./configure --prefix=/usr/local/ssl
make install
cd /etc/ld.so.conf.d
echo "/usr/local/ssl/lib" > libressl-3.7.conf
ldconfig -v
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
3. 下载并编译python3.7
export LDFLAGS="-L/usr/local/ssl/lib"
export CPPFLAGS="-I/usr/local/ssl/include"
export PKG_CONFIG_PATH="/usr/local/ssl/lib/pkgconfig"
wget https://www.python.org/ftp/python/3.7.12/Python-3.7.12.tgz
tar zxvf Python-3.7.12.tgz
cd Python-3.7.12
./configure --prefix=/usr/lib/python37/ --enable-optimizations --with-ssl
make install
ln -s /usr/lib/python37/bin/python3 /usr/bin/python3
ln -s /usr/lib/python37/bin/pip3 /usr/bin/pip3
cp /usr/lib64/python3.6/lib-dynload/_bz2.cpython-36m-x86_64-linux-gnu.so /usr/lib/python37/lib/python3.7/lib-dynload/_bz2.cpython-37m-x86_64-linux-gnu.so