nginx安装时配置出错openssl library in … not found和error: SSL modules require the OpenSSL library. 的彻底解决

2024-06-30 1503阅读

目            录

一、问题描述(错误现象描述)

二、问题查处过程

1、查看openssl的版本

2、定位openssl所在目录

3、配置参数加上 openssl的目录

4、重装openssl

三、问题解决

1、openssl库路径匹配

2、--with-openssl路径配置


一、问题描述(错误现象描述)

        我们的程序原来正常运行,由于客户服务器做了系统更新(具体更新什么,客户也不知道)。导致我们的nginx运行出现错误

nginx: [emerg] the “ssl” parameter requires ngx_http_ssl_module in /home/nginx. conf:83

         想了很多办法处理,都没有处理好,最后只有在客户的环境重新编译nginx。

        在重新编译Nginx的过程中,第一步配置./configure 就出现了错误,如下:

./configure  --prefix=/home/nginx-bin --with-http_ssl_module 

……………………………

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= option.

       注:客户服务器操作系统是 Red Hat Enterprise Linux 7.6

二、问题查处过程

1、查看openssl的版本

       看错误提示,应该 是nginx没有找到系统的中openssl的库文件,是不是ssl没有安装好?于是调用openssl version,能够清楚看到openssl版本

[root@localhost home]# openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017
[root@localhost home]#

       显然,openssl是安装好的。

2、定位openssl所在目录

        那就有可能是openssl的路径问题了,nginx安装程序找到的路径是错误的。

       通过whereis openssl查找安装路径,如下命令,可以找到多个路径。

[root@localhost home]# whereis openssl
openssl: /usr/bin/openssl /usr/lib64/openssl /usr/include/openssl /usr/share/man/man1/openssl.1ssl.gz
[root@localhost home]#

       然后查找对应的openssl 的文件,找出路径为/usr/include/openssl,如下:

[root@localhost  home]#
[root@localhost  home]# find / -name  ssl.h
/usr/include/openssl/ssl.h
[root@localhost  home]#

        因此可以确定,原来系统文件的库文件路径是/usr/include/openssl,显然前面命令提示的,在/usr/local/等路径上都找不到,主要是路径错误。

3、配置参数加上 openssl的目录

       于是,在nginx配置configure  上增路径,如下

./configure --prefix=/home/nginx-bin --with-http_ssl_module --with-openssl=/usr/include/openssl

      配置问题过程,一切正常,错误不在,但是出现的新的错误:      

[root@localhost nginx-1.18.0]# make
make -f objs/Makefile
make[1]: 进入目录“/home/nginx-1.18.0”
cd /usr/include/openssl \
&& if [ -f Makefile ]; then make clean; fi \
&& ./config --prefix=/usr/include/openssl/.openssl no-shared no-threads  \
&& make \
&& make install_sw LIBDIR=lib
/bin/sh:行2: ./config: 没有那个文件或目录
make[1]: *** [/usr/include/openssl/.openssl/include/openssl/ssl.h] 错误 127
make[1]: 离开目录“/home/nginx-1.18.0”
make: *** [build] 错误 2
[root@localhost nginx-1.18.0]#

4、重装openssl

       又出现新的问题,还是彻底一些,重装openssl吧!

       (1)首先登录openssl的官网:

                openssl的官网(https://www.openssl.org)

        (2)然后进入openssl的旧版本路径 :

                     [ Old Releases ] - /source/old/index.html

        (3)由于我以前的系统是OpenSSL 1.0.2k的版本,所以我尽量下载OpenSSL 1.0.2k或者一户的版本。我下载的还是OpenSSL 1.0.2k的版本,下载后安装,过程比较简单:

                ./configure

               Make && make install

        比较顺利,一切正常。

三、问题解决

       重装openssl,nginx编译还是有点问题,又做了如下两项工作,才彻底解决问题:

1、openssl库路径匹配

       编译新的openssl时,openssl库路径没有和nginx编译配置的路径匹配好,导致无法找到openssl的库文件,造成的编译的configure出错。

       因此要修改nginx中openssl的配置文件,找到nginx安装目录下的文件“uto/lib/openssl/conf”,然后进行编辑:

nginx安装时配置出错openssl library in … not found和error: SSL modules require the OpenSSL library. 的彻底解决

        把lib修改为正确的lib64,如下图:

nginx安装时配置出错openssl library in … not found和error: SSL modules require the OpenSSL library. 的彻底解决

2、--with-openssl路径配置

          --with-openssl= 需要指定openssl库源路径,所以要把这个参数设定为“openssl 安装文件的所在路径”,因此,改动如下:

./configure --prefix=/home/nginx-bin --with-http_ssl_module --with-openssl=/home/nginx1180/openssl-1.0.2k

        没有出错,接着make && make install,一切过程顺利,最后生成可以运行的nginx文件。

        把nginx执行文件替换原来的nginx文件,正常运行。

        这次问题得到彻底解决。

若想了解更多,可以“点击” 下面的 “威迪斯特 微信名片”,就会出现我的二维码。

VPS购买请点击我

免责声明:我们致力于保护作者版权,注重分享,被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理! 图片声明:本站部分配图来自人工智能系统AI生成,觅知网授权图片,PxHere摄影无版权图库和百度,360,搜狗等多加搜索引擎自动关键词搜索配图,如有侵权的图片,请第一时间联系我们,邮箱:ciyunidc@ciyunshuju.com。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!

目录[+]