【工具】Ubuntu 非root用户 安装openssl

openssl 下载 & 解压

openssl 下载地址
在这里插入图片描述

或者 https://www.openssl.org/source/openssl-1.1.1l.tar.gz

上传到服务器

解压

tar -zxvf openssl-1.1.1l.tar.gz

切换到openssl-1.1.1l目录

cd openssl-1.1.1l

指定安装路径

#./config --prefix=/your/path/to/openssl-1.1.1l no-zlib #注意添加no-zlib
mkdir ~/include # 若根目录没有include文件夹则创建,这里的路径是自定义的,不一定得是这个
./config --prefix=~/include no-zlib

Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1t (0x1010114fL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

**********************************************************************
***                                                                ***
***   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 file first)         ***
***                                                                ***
**********************************************************************

编译安装

make -j && make install

配置环境变量

因为是非Root安装,所以为了c++程序编译的时候能够找到openssl库,需要手动添加include_path

在.bashrc文件中添加以下配置,注意:我在配置时,直接复制粘贴source后没有生效,排查原因应该是输入问题,手打一遍后,source后成功生效,推荐尽量手打一遍以下配置,且尽量不要中文注释。

扫描二维码关注公众号,回复: 16283918 查看本文章
vim .bashrc

 #在PATH中找到可执行文件程序的路径。
export PATH ="~/include/openssl-1.1.1l/bin:$PATH"

#gcc找到头文件的路径
export C_INCLUDE_PATH="~/include/openssl-1.1.1l/include:$C_INCLUDE_PATH"

#g++找到头文件的路径
export CPLUS_INCLUDE_PATH="~/include/openssl-1.1.1l/include:$CPLUS_INCLUDE_PATH"

#找到动态链接库的路径
export LD_LIBRARY_PATH="~/include/openssl-1.1.1l/lib:$LD_LIBRARY_PATH"

#找到静态库的路径
export LIBRARY_PATH="~/include/openssl-1.1.1l/lib:$LIBRARY_PATH"
source .bashrc

验证是否安装成功

openssl version -a

如果正确安装,会显示自己指定路径信息。

OpenSSL 1.1.1t  7 Feb 2023
built on: Sat May 20 08:20:50 2023 UTC
platform: linux-x86_64
options:  bn(64,64) rc4(8x,int) des(int) idea(int) blowfish(ptr) 
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DNDEBUG
OPENSSLDIR: "/yourpath/01_develop_tools/openssl_libssl-dev/ssl"
ENGINESDIR: "/yourpath/01_develop_tools/openssl_libssl-dev/lib/engines-1.1"

猜你喜欢

转载自blog.csdn.net/guai7guai11/article/details/130783572