1、依赖包安装
下载依赖包
# 如果你的环境是离线环境,先用自己电脑上的可以连接互联网的虚拟机下载到本地,在上传到离线环境
yumdownloader --destdir=/tmp/bao --resolve openssl-devel perl-IPC-Cmd zlib zlib-devel libffi libffi-devel gcc gcc-c++
安装依赖包
cd /tmp/bao
rpm -Uvh --force --nodeps *.rpm
2、备份原来openssl
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
3、编译安装openss3.2.0
下载openssl-3.2
# 如果你的环境是离线环境,先用自己电脑上的可以连接互联网的虚拟机下载到本地,在上传到离线环境
cd /tmp
wget https://ftp.openssl.org/source/openssl-3.2.0.tar.gz
配置编译
tar -zxvf openssl-3.2.0.tar.gz # 解压安装包
cd openssl-3.2.0
# --prefix和--openssldir =指定安装目录、配置文件目录 。shared 来创建一个共享库。zlib =使用zlib库启用压缩
./config --prefix=/usr/local/openssl-3.2.0 --openssldir=/usr/local/openssl-3.2.0/ssl shared zlib
返回日志:
[root@redhad6 openssl-3.2.0]# ./config --prefix=/usr/local/openssl-3.2.0 --openssldir=/usr/local/openssl-3.2.0/ssl shared zlib
Configuring OpenSSL version 3.2.0 for target linux-x86_64
Using os-specific seed configuration
Created configdata.pm
Running configdata.pm
Created Makefile.in
Created Makefile
Created include/openssl/configuration.h
**********************************************************************
*** ***
*** OpenSSL has been successfully configured ***
*** ***
*** If you encounter a problem while building, please open an ***
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
*** and include the output from the following command: ***
*** ***
*** perl configdata.pm --dump ***
*** ***
*** (If you are new to OpenSSL, you might want to consult the ***
*** 'Troubleshooting' section in the INSTALL.md file first) ***
*** ***
**********************************************************************
执行编译和安装命令
make && make install
4、添加新的符号链接和指定lib路径
/usr/local/openssl-3.2.0/ 路径为上一步骤指定的安装目录 --prefix 安装路径
添加新的符号链接
ln -s /usr/local/openssl-3.2.0/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl-3.2.0/include/openssl /usr/include/openssl
指定lib路径
echo "/usr/local/openssl-3.2.0/lib64" >> /etc/ld.so.conf
# 重新加载动态链接库
ldconfig -v
5、验证安装
# 查看安装版本
openssl version -a
# 查看动态依赖关系
ldd /usr/local/openssl-3.2.0/bin/openssl
# 查看安装路径
which openssl
参考:
1、[CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1-腾讯云开发者社区-腾讯云 (tencent.com)]
2、/etc/ld.so.conf详解