【问题解决】源码安装Nginx提示找不到openssl library

问题背景

最近测试同事说有一台服务器执行源码安装Nginx脚本出现openssl not found的错误解决不了让我帮忙看看,ssh连接上去后发现这台服务器安装了 CentOS7.9操作系统,并且已经安装了 openssl-devel 库,理论上不会有问题。

然而,就在重装多次 openssl相关软件包后,感觉问题不大正常,于是再次仔细查看报错信息:

checking for OpenSSL library ... not found
checking for OpenSSL library in /usr/local/ ... not found
checking for OpenSSL library in /usr/pkg/ ... not found
checking for OpenSSL library in /opt/local/ ... not found

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

大意是没找到OpenSSL库,而Nginx的SSL模块需要OpenSSL库,要么禁用这个模块,要么安装OpenSSL库;也可以通过指定OpenSSL源码位置来静态编译OpenSSL供Nginx使用。

检查openssl-devel安装情况 yum list installed |grep openssl-devel,发现的确安装了

[root@cfs-ctp nginx]# yum list installed |grep openssl-devel
openssl-devel.x86_64                       1:1.0.2k-25.el7_9           @updates

尝试执行了下 openssl version 查看openssl的版本

[root@cfs-ctp nginx]# openssl version
openssl: relocation error: openssl: symbol OPENSSL_init_ssl, version OPENSSL_1_1_0 not defined in file libssl.so.1.1 with link time reference

yum安装的版本是1.0.2k,而提示却是OPENSSL_1_1_0,我怀疑 openssl 安装有问题。

解决方法

由于在网上百度到OpenSSL library in /usr/local/ … not found这种标题的帖子解决办法都非常离谱——指定OpenSSL源码静态编译 或 手动编译OpenSSL后复制到某个位置,再有怀疑OpenSSL安装有问题,直接去查OpenSSL的报错信息,发现了全网(截至2022/09/08)唯一一篇情况大致相同的贴子,来自ArchLinux论坛 https://archlinuxarm.org/forum/viewtopic.php?t=11679&p=55714

于是全局搜索下 openssl 目录,看看有没有源码安装目录

[root@cfs-ctp ~]# find / -name openssl
find: ‘/proc/42458’: 没有那个文件或目录
/etc/pki/ca-trust/extracted/openssl
/root/nginx/nginx-1.22.0/auto/lib/openssl
/usr/bin/openssl
/usr/lib64/openssl
/usr/include/openssl
/data/jq/rpms/openssl-1.1.1a/test/ossl_shim/include/openssl
/data/jq/rpms/openssl-1.1.1a/apps/openssl
/data/jq/rpms/openssl-1.1.1a/include/openssl
/data/jq/rpms/tengine-2.3.0/auto/lib/openssl

的确发现1.1.1版本的源码目录,进入后执行卸载操作

cd /data/jq/rpms/openssl-1.1.1a
make uninstall

再次执行源码安装nginx的脚本,一切正常。

提示:源码安装系统组件一定要保留编译安装目录,不然出现这种情况基本就得重装系统了。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

东北小狐狸-Hellxz

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值