1. 安裝
- 查看當前openssl版本:
openssl version
顯示為1.0版本
- 編譯安裝Python3.10時需要openssl1.1.1,所以這里手動刪除openssl1.0
yum remove openssl
- 下載 openssl 安裝包
-
官網(wǎng)地址
QQ截圖20230202163827.png - 解壓并進入openssl3.0.7路徑下:
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. 錯誤
- 編譯OpenSSL 3.0.7 時報錯怠惶,錯誤信息如下
[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. 解決
- 安裝perl-CPAN
yum install -y perl-CPAN
- 進入CPAN的shell模式,首次進入需要配置shell家制,按照提示操作即可(本人perl小白,全部選擇默認配置泡一,高手請根據(jù)提示自行選擇)
[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]
-
到這邊根據(jù)提示颤殴,直接默認 yes 一路下去
QQ截圖20230202154248.png -
cpan[1]> install IPC/Cmd.pm 安裝,這邊結(jié)束了鼻忠,直接Ctrl + D 退出去
QQ截圖20230202154621.png -
再次輸入命令 ./config --prefix=/usr/local/openssl
QQ截圖20230202154830.png 繼續(xù)安裝 openssl
make -j 2
make install
- 創(chuàng)建鏈接
ln -sf /usr/local/openssl/bin/openssl /usr/bin/openssl
- 修改 ld.so.conf
vim /etc/ld.so.conf
在文件末尾添加一行代碼:
/usr/local/openssl/lib
- 使配置生效:
ldconfig -v
- 然后在任意路徑下輸入命令:
openssl version
可以看到版本為openssl 3.0.7
按照上面的方法肯定沒問題诅病,問題就是你安裝的 openssl 地址可能不一樣,那就會報下面的錯誤
4. 運行報錯
- openssl version
[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
- 因為創(chuàng)建軟鏈接的時候路徑錯了粥烁,我們需要創(chuàng)建鏈接
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
-
注意我這個路徑 ln -s /usr/local/openssl/lib64/libssl.so.3 贤笆, 因為我安裝 openssl 目錄就在這里
QQ截圖20230202162653.png -
執(zhí)行 ldconfig -v 使配置生效,重新輸入 openssl version 讨阻, 成功芥永!
QQ截圖20230202163316.png
5. 總結(jié)
- 參考別人的文檔不要按部就班,要根據(jù)自己的實際情況靈活變通钝吮。
- 要記錄過程并總結(jié)埋涧,方便自己就是方便他人。