说明
由于openssl不提供1.X版本,只提供3.x版本,现以openssl3.0+nginx1.26源码安装
实施
安装依赖依赖
1 2
| yum -y groupinstall "Development tools" yum install gcc openssl-devel bzip2-devel libffi-devel perl-IPC-Cmd
|
下载 openssl 源码包
1 2 3
| wget https://www.openssl.org/source/openssl-3.0.13.tar.gz tar -zxf openssl-3.0.13.tar.gz pushd openssl-3.0.13 > /dev/null
|
编译 openssl 安装
1 2 3
| ./config --prefix=/usr/local/openssl shared zlib cpu_num=`cat /proc/stat | grep cpu[0-9] -c` make -j${cpu_num} && make install
|
备份老 openssl
1 2
| mv /usr/bin/openssl /usr/bin/openssl.oldbak mv /usr/include/openssl /usr/include/openssl.oldbak
|
创建 openssl 软链接
1 2 3 4
| ln -sf /usr/local/openssl/bin/openssl /usr/bin/openssl ln -sf /usr/local/openssl/include/openssl /usr/include/openssl ln -sf /usr/local/openssl/lib64/libssl.so.3 /usr/lib64/libssl.so.3 ln -sf /usr/local/openssl/lib64/libcrypto.so.3 /usr/lib64/libcrypto.so.3
|
更新加载动态连接库数据
1 2 3 4
| #openssl放弃了32位,默认采用64位
echo /usr/local/openssl/lib64 >> /etc/ld.so.conf ldconfig -v
|
检查 openssl 版本
1 2 3
| openssl version popd > /dev/null rm -rf openssl-3.0.13
|
下载 Python3 源码包
1 2 3
| wget https://www.python.org/ftp/python/3.10.14/Python-3.10.14.tgz tar -zxf Python-3.10.14.tgz pushd Python-3.10.14 > /dev/null
|
编译安装
编译完成指定安装到/usr/local/python3
1 2 3
| ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl --with-ensurepip=yes CFLAGS="-I/usr/local/openssl/include" LDFLAGS="-L/usr/local/openssl/lib64" cpu_num=`cat /proc/stat | grep cpu[0-9] -c` make -j${cpu_num} && make install
|
添加环境变量
1 2
| echo "export PATH=/usr/local/python3/bin:$PATH" >> /etc/profile source /etc/profile
|
创建 python3 软链接
1 2
| ln -sf /usr/local/python3/bin/python3.10 /usr/bin/python3 ln -sf /usr/local/python3/bin/pip3.10 /usr/bin/pip3
|
检查 Python 版本
1 2 3 4
| python3 --version pip3 --version popd > /dev/null rm -rf Python-3.10*
|