目            录

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

二、问题查处过程

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=<path> 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”,然后进行编辑:

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

2、--with-openssl路径配置

          --with-openssl=<dir> 需要指定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文件,正常运行。

        这次问题得到彻底解决。

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

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐