海思hi3559a nginx 移植

1.主机操作系统为ubuntu 18.04。交叉编译需要用到的软件包为
zlib-1.2.8.tar.bz2
上面文件可通过此下载链接下载
nginx.v1.6.2.tar.bz2
上面文件可通过此下载链接下载
2.交叉编译nginx
1)将zlib nginx包解压

tar -xvf zlib-1.2.8.tar.bz2
tar -xvf nginx.v1.6.2.tar.bz2

2)配置configure

cd nginx/nginx-1.6.2
mkdir nginx
vi b.sh
CC_PATH=/opt/hisi-linux/x86-arm/aarch64-himix100-linux/bin/aarch64-himix100-linux-gcc#交叉编译工具路径
CPP_PATH=/opt/hisi-linux/x86-arm/aarch64-himix100-linux/bin/aarch64-himix100-linux-g++#交叉编译工具路径
HOME_NGINX=/xxxx/xxxx/xxxx/xxx/ #解压出来的路径可用pwd代替
#./configure --prefix=/opt/project/hi3559a/lib_add/nginx \
./configure --prefix=./nginx \
--add-module=$HOME_NGINX/nginx/arut-nginx-rtmp-module-7a35372 \
--with-zlib=$HOME_NGINX/zlib-1.2.8 \
--without-pcre --without-http_rewrite_module \
--with-http_ssl_module \
--with-openssl=$HOME_NGINX/nginx/openssl-1.0.2 \
--with-cc=$CC_PATH  \
--with-cpp=$CPP_PATH

3)交叉编译

./b.sh
make ;make install

3.遇到的坑
1)error: 'NGX_SYS_NERR’错误

src/os/unix/ngx_errno.c: In function 'ngx_strerror':
src/os/unix/ngx_errno.c:37:31: error: 'NGX_SYS_NERR' undeclared (first use in this function)
     msg = ((ngx_uint_t) err < NGX_SYS_NERR) ? &ngx_sys_errlist[err]:
                               ^~~~~~~~~~~~
src/os/unix/ngx_errno.c:37:31: note: each undeclared identifier is reported only once for each function it appears in
src/os/unix/ngx_errno.c: In function 'ngx_strerror_init':
src/os/unix/ngx_errno.c:58:11: error: 'NGX_SYS_NERR' undeclared (first use in this function)
     len = NGX_SYS_NERR * sizeof(ngx_str_t);
           ^~~~~~~~~~~~
objs/Makefile:680: recipe for target 'objs/src/os/unix/ngx_errno.o' failed
make[1]: *** [objs/src/os/unix/ngx_errno.o] Error 1
make[1]: Leaving directory '/opt/project/hi3559a/lib_src/nginx/nginx-1.6.2'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2

出错的原因仍然是因为交叉编译程序无法本地运行,导致NGX_SYS_NERR宏没有赋值。解决办法,手动编辑 objs/ngx_auto_config.h,加上

vi objs/ngx_auto_config.h
#ifndef NGX_SYS_NERR
#define NGX_SYS_NERR  132
#endif

2)ngx_shm_free错误

objs/src/core/ngx_cycle.o: In function `ngx_init_cycle':
/opt/project/hi3559a/lib_src/nginx/nginx-1.6.2/src/core/ngx_cycle.c:457: undefined reference to `ngx_shm_free'
/opt/project/hi3559a/lib_src/nginx/nginx-1.6.2/src/core/ngx_cycle.c:462: undefined reference to `ngx_shm_alloc'
/opt/project/hi3559a/lib_src/nginx/nginx-1.6.2/src/core/ngx_cycle.c:648: undefined reference to `ngx_shm_free'
objs/src/event/ngx_event.o: In function `ngx_event_module_init':
/opt/project/hi3559a/lib_src/nginx/nginx-1.6.2/src/event/ngx_event.c:525: undefined reference to `ngx_shm_alloc'
collect2: error: ld returned 1 exit status
objs/Makefile:256: recipe for target 'objs/nginx' failed
make[1]: *** [objs/nginx] Error 1
make[1]: Leaving directory '/opt/project/hi3559a/lib_src/nginx/nginx-1.6.2'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2

解决办法

vi objs/ngx_auto_config.h
#ifndef NGX_HAVE_SYSVSHM
#define NGX_HAVE_SYSVSHM 1
#endif

4.移植到hi3559a
将当前目录下的nginx目录下所有移植到海思3559a上
修改nginx/conf/nginx.conf

vi nginx.conf 
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

修改如下

user  root;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

运行

./nginx -c /opt/project/hi3559a/lib_add/nginx/conf/nginx.conf -p /opt/project/hi3559a/lib_add/nginx/

结束

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值