CentOS

CentOS 安装 openssl 最新版本

2023-02-01  本文已影响0人  Rinaloving

1. 安装

openssl version
显示为1.0版本
yum remove openssl
 tar -zxvf openssl-3.0.7.tar.gz 
 cd openssl-3.0.7/
 ./config --prefix=/usr/local/openssl
 make -j 2
 make install

Can't locate IPC/Cmd.pm in @INC

2. 错误

[root@VM-0-7-centos openssl-3.0.7]# ./config --prefix=/usr/local/openssl
Can't locate IPC/Cmd.pm in @INC (@INC contains: /usr/local/openssl-3.0.7/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 . /usr/local/openssl-3.0.7/external/perl/Text-Template-1.56/lib) at /usr/local/openssl-3.0.7/util/perl/OpenSSL/config.pm line 19.
BEGIN failed--compilation aborted at /usr/local/openssl-3.0.7/util/perl/OpenSSL/config.pm line 19.
Compilation failed in require at /usr/local/openssl-3.0.7/Configure line 23.
BEGIN failed--compilation aborted at /usr/local/openssl-3.0.7/Configure line 23.

3. 解决

yum install -y perl-CPAN
[root@VM-0-7-centos openssl-3.0.7]# perl -MCPAN -e shell

CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.

Would you like to configure as much as possible automatically? [yes] y

 <install_help>

Warning: You do not have write permission for Perl library directories.

To install modules, you need to configure a local Perl library directory or
escalate your privileges.  CPAN can help you by bootstrapping the local::lib
module or by configuring itself to use 'sudo' (if available).  You may also
resolve this problem manually if you need to customize your setup.

What approach do you want?  (Choose 'local::lib', 'sudo' or 'manual')
 [local::lib] 
make -j 2
make install
ln -sf /usr/local/openssl/bin/openssl /usr/bin/openssl
vim /etc/ld.so.conf
在文件末尾添加一行代码:
/usr/local/openssl/lib
ldconfig -v
openssl version

可以看到版本为openssl 3.0.7

按照上面的方法肯定没问题,问题就是你安装的 openssl 地址可能不一样,那就会报下面的错误

4. 运行报错

[root@VM-0-7-centos lib64]# openssl version
openssl: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory
ln -s /usr/local/openssl/lib64/libssl.so.3 /usr/lib/libssl.so.3
ln -s /usr/local/openssl/lib64/libcrypto.so.3 /usr/lib/libcrypto.so.3

5. 总结

上一篇下一篇

猜你喜欢

热点阅读