1.安装编译依赖包:
sudo yum -y install epel-release
sudo yum install wget make cmake gcc bzip2-devel libffi-devel zlib-devel
2.确认gcc版本:
$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
3.升级openssl至1.1.X版本:
3.1 下载openssl安装包
#附件会有安装包以及安装脚本
cd ~/python_3.11_install/
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
3.2 备份
mv /usr/bin/openssl /usr/bin/openssl.bak
3.3 解压目录并编译安装
#解压压缩包
tar -zxvf ~/python_3.11_install/openssl-1.1.1k.tar.gz
#进入安装目录编译安装
cd ~/python_3.11_install/openssl-1.1.1k
./config --prefix=/usr/local/openssl
make && make install
3.4 创建软连接,查看升级是否成功
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
echo '/usr/local/openssl/lib' >> /etc/ld.so.conf
ldconfig -v[root@localhost openssl-1.1.1k]# openssl version
OpenSSL 1.1.1k 25 Mar 2021
4. 安装python3.11
4.1 下载python3.11安装包
wget https://www.python.org/ftp/python/3.11.2/Python-3.11.2.tgz
4.2 解压安装
tar xvf Python-3.11.2.tgz
cd Python-3.11.2/
设置编译环境
LDFLAGS="${LDFLAGS} -Wl,-rpath=/usr/local/openssl/lib" ./configure --with-openssl=/usr/local/openssl
编译安装
make
make altinstall
4.3 验证Python版本以及OpenSSL 库是否正常工作
[root@localhost Python-3.11.2]# python3.11 --version
Python 3.11.2
[root@localhost Python-3.11.2]# python3.11
Python 3.11.2 (main, Apr 10 2025, 18:16:49) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.1.1k 25 Mar 2021'
>>> exit()
5. 验证下pip版本
[root@localhost Python-3.11.2]# pip3.11 --version
pip 22.3.1 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)
#我们安装个psutil模块试试
[root@localhost Python-3.11.2]# pip3.11 install psutil
Collecting psutilDownloading psutil-7.0.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (277 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 278.0/278.0 kB 34.5 kB/s eta 0:00:00
Installing collected packages: psutil
Successfully installed psutil-7.0.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv[notice] A new release of pip available: 22.3.1 -> 25.0.1
[notice] To update, run: pip3.11 install --upgrade pip