mac上nginx扩展nginx_upstream_check_module

安装过程参考:https://www.cnblogs.com/ztlsir/p/8945043.html

问题解决

  1. 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路径是默认的安装路径,如有不同请自行修改

./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
  1. 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

在本地找到相关文件,我本地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"

修改完后重新执行./configure,然后执行make

  1. 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)终结,直接将55行的#pragma pack()改成#pragma pack(pop),理论上在代码最后加上pop语句应该也可以。对c相关语言没有太多研究,这里这是为了解决问题。再次执行make命令,成功,完美。

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容