环境
CentOS 7.9
python3部署
安装依赖
# sudo yum groupinstall 'Development Tools'
sudo yum install openssl-devel sqlite-devel bzip2-devel xz-devel ncurses-devel zlib-devel readline-devel tk-devel gdbm-devel db5-devel libffi-devel
1.OpenSSL 编译安装
下载 OpenSSL 1.1.1 源代码
cd /usr/local/python3
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
tar -xzvf openssl-1.1.1k.tar.gz
cd openssl-1.1.1k
编译和安装 OpenSSL 1.1.1
./config --prefix=/usr/local/openssl-1.1.1k
make
make install
2.Python 编译安装
cd /usr/local/python3
wget https://www.python.org/ftp/python/3.10.14/Python-3.10.14.tgz
tar -xzvf Python-3.10.14.tgz
cd Python-3.10.14
配置、编译和安装 Python
export PATH=/usr/local/openssl-1.1.1k/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/openssl-1.1.1k/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/usr/local/openssl-1.1.1k/lib/pkgconfig:$PKG_CONFIG_PATH
sudo ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl-1.1.1k
sudo make
sudo make install
Installing collected packages: setuptools, pip
Successfully installed pip-23.0.1 setuptools-65.5.0
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
验证安装
/usr/local/python3/bin/python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"
/usr/local/openssl-1.1.1k/bin/openssl version