nginx 编译安装1.17.3版本,添加openssl参数报错问题解决
admin
2023-03-12 03:42:02
0

背景

    最近在升级nginx1.14.1到nginx1.17.3版本时,发现了一个openssl的报错,记录一下问题的发生以及解决过程,供大家参考。


问题

    升级nginx时,我按照惯例,使用原版本的编译参数,来进行1.17.3新版本的编译,如下:

# /usr/local/nginx/sbin/nginx -V
取得编译参数:
--prefix=/usr/local/nginx --with-http_ssl_module --with-openssl=/usr/local/openssl --with-http_stub_status_module --with-http_dav_module --with-http_realip_module --with-http_gzip_static_module --with-http_v2_module

     利用旧版本的编译参数来编译新版本nginx,make的时候,发现出现了错误,操作与信息如下:

# tar -zxvf nginx-1.17.3.tar.gz
# cd nginx-1.17.3
# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl=/usr/local/openssl --with-http_stub_status_module --with-http_dav_module --with-http_realip_module --with-http_gzip_static_module --with-http_v2_module
# make
make -f objs/Makefile
make[1]: Entering directory `/root/soft/nginx-1.17.3'
cd /usr/local/openssl \
&& if [ -f Makefile ]; then make clean; fi \
&& ./config --prefix=/usr/local/openssl/.openssl no-shared no-threads  \
&& make \
&& make install_sw LIBDIR=lib
/bin/sh: line 2: ./config: No such file or directory
make[1]: *** [/usr/local/openssl/.openssl/include/openssl/ssl.h] Error 127
make[1]: Leaving directory `

    从报错信息上看,可以看到编译是openssl相关的组件报错了,可能是“--with-openssl=/usr/local/openssl” 这个参数导致。这里提到了“/usr/local/openssl/.openssl/include/openssl/ssl.h”这个文件,我尝试去找这个文件,发现文件找不到:(/usr/local/openssl是我自己安装的openssl)

# ll /usr/local/openssl/.openssl/
ls: cannot access /usr/local/openssl/.openssl/: No such file or directory

    可以发现.openssl这个目录本身是不存在的,应该是nginx 1.17.3版本编译的时候默认去找了“/usr/local/openssl/.openssl/”这个目录,所以导致了make失败。


解决

     发现了问题可能的原因后,尝试修改一下nginx1.17.3添加openssl模块时候的相关编译信息(auto/lib/openssl/conf):

# vi auto/lib/openssl/conf
            CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"
            CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"
            CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"
            CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"
            
//在该文件中,看到openssl的core相关目录,都被添加上了.openssl这级目录,尝试修改目录信息,去除.openssl这级目录:   
# more auto/lib/open/ssl
            CORE_INCS="$CORE_INCS $OPENSSL/include"
            CORE_DEPS="$CORE_DEPS $OPENSSL/include/openssl/ssl.h"
            CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libssl.a"
            CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libcrypto.a"

      修改完auto/lib/openssl/conf的信息之后,重新编译安装nginx1.17.3,即可正常编译安装成功。

# make clean
# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl=/usr/local/openssl --with-http_stub_status_module --with-http_dav_module --with-http_realip_module --with-http_gzip_static_module --with-http_v2_module
# make && make install


相关内容

热门资讯

今日重磅消息“德州之夜.开挂神... 网上科普关于“德州之夜有没有挂”话题很是火热,小编也是针对德州之夜作*弊开挂的方法以及开挂对应的知识...
玩家最新攻略“上海滩.辅助开挂... 您好:上海滩这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9752949】很多玩家在这款游戏中...
玩家分享攻略“问鼎娱乐.真的有... 家人们!今天小编来为大家解答问鼎娱乐透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里买很...
【第一消息】“老表逗娱碰胡.开... 【第一消息】“老表逗娱碰胡.开挂神器?”太坑了果然有挂您好,老表逗娱碰胡这个游戏其实有挂的,确实是有...
今日重磅消息“海岛互娱.可以开... 家人们!今天小编来为大家解答海岛互娱透视挂怎么安装这个问题咨询软件客服徽9784099的挂在哪里买很...
重磅消息“火神牛牛.辅助器?”... 重磅消息“火神牛牛.辅助器?”详细开挂教程您好,火神牛牛这个游戏其实有挂的,确实是有挂的,需要了解加...
重磅消息“情怀娱乐.可以开挂吗... 家人们!今天小编来为大家解答情怀娱乐透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里买很...
终于明白“一喜棋牌.到底有挂吗... 家人们!今天小编来为大家解答一喜棋牌透视挂怎么安装这个问题咨询软件客服徽9784099的挂在哪里买很...
终于明白“微乐卡五星.开挂神器... 您好:微乐卡五星这款游戏可以开挂,确实是有挂的,需要了解加客服微信【4282891】很多玩家在这款游...
终于懂了“德扑之星.可以开挂吗... 您好:德扑之星这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9784099】很多玩家在这款游戏...