安裝過程參考:https://www.cnblogs.com/ztlsir/p/8945043.html
問題解決
- OpenSSL問題
報錯:
./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.
解決方案:使用brew安裝openssl
brew install openssl
然后指定openssl路徑僻他,下面是我修改后的命令搀军,openssl路徑是默認(rèn)的安裝路徑辐益,如有不同請自行修改
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --add-module=../nginx_upstream_check_module-master --add-module=../nginx-upstream-fair-master --with-openssl=/usr/local/Cellar/openssl@1.1/1.1.1g
- openssl路徑錯誤
報錯:
/Library/Developer/CommandLineTools/usr/bin/make -f objs/Makefile
cd /usr/local/Cellar/openssl@1.1/1.1.1g \
&& if [ -f Makefile ]; then /Library/Developer/CommandLineTools/usr/bin/make clean; fi \
&& ./config --prefix=/usr/local/Cellar/openssl@1.1/1.1.1g/.openssl no-shared no-threads \
&& /Library/Developer/CommandLineTools/usr/bin/make \
&& /Library/Developer/CommandLineTools/usr/bin/make install_sw LIBDIR=lib
/bin/sh: ./config: No such file or directory
make[1]: *** [/usr/local/Cellar/openssl@1.1/1.1.1g/.openssl/include/openssl/ssl.h] Error 127
make: *** [build] Error 2
在本地找到相關(guān)文件,我本地ssl.h的正確路徑為/usr/local/Cellar/openssl@1.1/1.1.1g/include/openssl/ssl.h
,修改nginx代碼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_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"
修改完后重新執(zhí)行./configure
,然后執(zhí)行make
- nginx_upstream_check_module-master模塊會報錯
報錯:
../nginx_upstream_check_module-master/ngx_http_upstream_check_module.c:16:9: error: unterminated '#pragma pack (push, ...)' at end of file
[-Werror,-Wpragma-pack]
#pragma pack(push, 1)
^
../nginx_upstream_check_module-master/ngx_http_upstream_check_module.c:55:9: note: did you intend to use '#pragma pack (pop)' instead of
'#pragma pack()'?
#pragma pack()
^
pop
1 error generated.
make[1]: *** [objs/addon/nginx_upstream_check_module-master/ngx_http_upstream_check_module.o] Error 1
make: *** [build] Error 2
參考文檔:https://gcc.gnu.org/onlinedocs/gcc-5.2.0/gcc/Structure-Packing-Pragmas.html#Structure-Packing-Pragmas袖牙,使用了pack(push)
,必須使用一個#pragma pack(pop)
終結(jié)舅锄,直接將55行的#pragma pack()
改成#pragma pack(pop)
鞭达,理論上在代碼最后加上pop語句應(yīng)該也可以。對c相關(guān)語言沒有太多研究皇忿,這里這是為了解決問題畴蹭。再次執(zhí)行make
命令,成功鳍烁,完美撮胧。