十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
背景
最近在升級nginx1.14.1到nginx1.17.3版本時,發(fā)現(xiàn)了一個openssl的報錯,記錄一下問題的發(fā)生以及解決過程,供大家參考。
問題
升級nginx時,我按照慣例,使用原版本的編譯參數(shù),來進行1.17.3新版本的編譯,如下:
#?/usr/local/nginx/sbin/nginx?-V 取得編譯參數(shù): --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利用舊版本的編譯參數(shù)來編譯新版本nginx,make的時候,發(fā)現(xiàn)出現(xiàn)了錯誤,操作與信息如下:
#?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相關(guān)的組件報錯了,可能是“--with-openssl=/usr/local/openssl” 這個參數(shù)導致。這里提到了“/usr/local/openssl/.openssl/include/openssl/ssl.h”這個文件,我嘗試去找這個文件,發(fā)現(xiàn)文件找不到:(/usr/local/openssl是我自己安裝的openssl)
#?ll?/usr/local/openssl/.openssl/ ls:?cannot?access?/usr/local/openssl/.openssl/:?No?such?file?or?directory可以發(fā)現(xiàn).openssl這個目錄本身是不存在的,應該是nginx 1.17.3版本編譯的時候默認去找了“/usr/local/openssl/.openssl/”這個目錄,所以導致了make失敗。
解決
? ?發(fā)現(xiàn)了問題可能的原因后,嘗試修改一下nginx1.17.3添加openssl模塊時候的相關(guān)編譯信息(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相關(guān)目錄,都被添加上了.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另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。