CentOS7编译安装OpenSSL3.1
CentOS7编译安装OpenSSL3.1
1.下载Openssl源码包
[root@localhost ~]# wget https://www.openssl.org/source/openssl-3.1.0.tar.gz
2.解压安装
[root@localhost ~]# tar -xvf openssl-3.1.0.tar.gz -C /usr/local/ [root@localhost ~]# cd /usr/local/openssl-3.1.0/ [root@localhost openssl-3.1.0]# ./config --prefix=/usr/local/openssl
如果报错为: 缺少IPC/Cmd.pm模块
[root@localhost openssl-3.1.0]# ./config --prefix=/usr/local/openssl Can't locate IPC/Cmd.pm in @INC (@INC contains: /root/Downloads/openssl-3.1.0/util/perl /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /root/Downloads/openssl-3.1.0/external/perl/Text-Template-1.56/lib) at /root/Downloads/openssl-3.1.0/util/perl/OpenSSL/config.pm line 18. BEGIN failed--compilation aborted at /root/Downloads/openssl-3.1.0/util/perl/OpenSSL/config.pm line 18. Compilation failed in require at /root/Downloads/openssl-3.1.0/Configure line 23. BEGIN failed--compilation aborted at /root/Downloads/openssl-3.1.0/Configure line 23.
解决方法:
[root@localhost openssl-3.1.0]# yum -y install perl-IPC-Cmd
3.重新编译配置:
[root@localhost openssl-3.1.0]# ./config --prefix=/usr/local/openssl [root@localhost openssl-3.1.0]# make -j 32 [root@localhost openssl-3.1.0]# make install
libssl.so.3文件在/usr/local/openssl/lib64目录下面,需要配置到共享库中:
[root@localhost ~]# vim /etc/ld.so.conf include ld.so.conf.d/*.conf /usr/local/openssl/lib64
加载生效:
[root@localhost ~]# ldconfig
做软连接:
[root@localhost ~]# mv /usr/bin/openssl /usr/bin/openssl.bak [root@localhost ~]# mv /usr/include/openssl /usr/include/openssl.bak [root@localhost ~]# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl [root@localhost ~]# ln -s /usr/local/openssl/include/openssl/ /usr/include/openssl
查看Openssl版本:
[root@localhost ~]# openssl version OpenSSL 3.1.0 14 Mar 2023 (Library: OpenSSL 3.1.0 14 Mar 2023)