欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

nginx交叉编译以及https配置使用

程序员文章站 2022-07-14 11:57:18
...

这里记录一下所遇到的问题。

  1. 下载pcre,openssl,nginx源码解压到同级目录。

  2. 配置环境变量:
    export INSTALL_PATH=/usr/local/nginx //安装路径会写入nginx可执行程序
    export CC_PATH=/var/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin/aarch64-linux-gnu-gcc
    export CPP_PATH=/var/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin/aarch64-linux-gnu-g++

  3. 配置configure:

    ./configure --prefix=KaTeX parse error: Expected 'EOF', got '\ ' at position 15: INSTALL_PATH \̲ ̲ --without-http…CC_PATH
    –with-cpp=$CPP_PATH

    1. 编译:

make;make install

遇到的问题

这里补上漏掉的问题:
configure错误:
1

checking for C compiler ... found but is not working

./configure: error: C compiler arm-hisiv400-linux-gcc is not found

vi auto/cc/name ,找到

if [ $ngx_found = no ]; then
        echo
        echo $0: error: C compiler $CC is not found
        echo
        exit 1
    fi

configure首先会编译一个小测试程序,通过测试其运行结果来判断编译器是否能正常工作,由于交叉编译器所编译出的程序是无法在编译主机上运行的,故而产生此错误。exit 1 注释掉。

2

autotest:Syntax error: Unterminated quoted string bytes 
./configure : error:can not detect int size

vi auto/types/sizeof ,
ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS
改为
ngx_test="gcc $CC_TEST_FLAGS $CC_AUX_FLAGS

make错误:
3
src/core/ngx_rwlock.c:125:2: error: #error ngx_atomic_cmp_set() is not defined!
这个错误需要将 configure时 加入–without-http_upstream_zone_module参数。

1nginx交叉编译以及https配置使用pcre没有指定host。在nginx/objs/Makefile 修改

/home/pcre-8.36/Makefile:       objs/Makefile
        cd /home/pcre-8.36 \
        && if [ -f Makefile ]; then $(MAKE) distclean; fi \        
        && CC="$(CC)" CFLAGS="-O2 -fomit-frame-pointer -pipe " \
        ./configure --disable-shared

最后一行增加 --host=aarch64-linux-gnu

2
nginx交叉编译以及https配置使用
看提示是在unix系统openssl需要使用config而不是Configure。修改nginx/objs/Makefile

/home/openssl-1.0.2s/.openssl/include/openssl/ssl.h:    objs/Makefile
        cd /home/openssl-1.0.2s \
        && if [ -f Makefile ]; then $(MAKE) clean; fi \
        && ./Configure --prefix=/home/openssl-1.0.2s/.openssl no-shared no-threads --cross-compile-prefix=/var/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin/aarch64-linux-gnu- \
        && $(MAKE) \
        && $(MAKE) install_sw LIBDIR=lib

将Configure改为config。

3 nginx交叉编译以及https配置使用
-m64 是64位操作系统,但是不知道为什么我的编译器识别不了,所以只能到openssl文件夹单独编译openssl。需要删除openssl的Makefile中所有 -m64 的地方,有两处。SHARED_LDFLAGS=-m64这里整行删除。

4nginx交叉编译以及https配置使用
这个需要修改nginx/objs/Makefile , 第2个问题中config行增加 no-asm ,禁用汇编。重新make,再到openssl文件夹修改Makefile后make;make install,回到nginx文件夹重新make

5
nginx交叉编译以及https配置使用
需要修改 objs/ngx_auto_config.h,增加

#ifndef NGX_SYS_NERR
#define NGX_SYS_NERR  132
#endif

nginx交叉编译以及https配置使用这个问题需要修改相同位置

#ifndef NGX_HAVE_SYSVSHM
#define NGX_HAVE_SYSVSHM 1
#endif

make成功后make install 安装到设置的安装目录。

参考文章:
https://blog.csdn.net/fish43237/article/details/40515897
https://www.jianshu.com/p/5d9b60f7b262