nginx交叉编译

作者

QQ群:852283276
微信:arm80x86
微信公众号:青儿创客基地
B站:主页 https://space.bilibili.com/208826118

参考

nginx开源代码的交叉编译
交叉编译Hi3536上面使用的nginx
交叉编译 nginx ,基于mipsel平台
交叉编译 nginx
nginx1.6.3交叉编译成功的代码
nginx 交叉编译 ( 上 )
nginx 交叉编译 (下)
nginx 交叉编译及上传大文件处理
openssl交叉编译问题
为64位ARMv8架构开发板交叉编译openssl-1.0.2l
交叉编译openssl

下载

nginx: download
zlib home page
PCRE - Perl Compatible Regular Expressions
openssl

交叉编译

编辑auto/cc/name,

ngx_feature_run=yes -> ngx_feature_run=no

编辑auto/types/sizeof

$CC $CC_TEST_FLAGS $CC_AUX_FLAGS -> gcc $CC_TEST_FLAGS $CC_AUX_FLAGS
ngx_size=`$NGX_AUTOTEST` -> ngx_size=4 (armv7)

执行./configure

$ ./configure --with-cc=arm-xilinx-linux-gnueabi-gcc --with-cpp=arm-xilinx-linux-gnueabi-g++ --prefix=$cur_path/zynq-static-$PETALINUX_VER --with-pcre=$parent_path/pcre-8.43 --with-zlib=$parent_path/zlib-1.2.11 --with-openssl=$parent_path/openssl-1.0.2r  --user=root --group=root

编辑objs/Makefile,更新pcre和openssl的编译命令,

$ ./configure --disable-shared -> ./configure --disable-shared --host=arm-xilinx-linux-gnueabi
$ ./config --prefix=/home/zc/fdk_develop/package/openssl-1.1.0i/.openssl no-shared no-threads -> ./config --prefix=/home/zc/fdk_develop/package/openssl-1.1.0i/.openssl no-shared no-threads no-asm --cross-compile-prefix=arm-xilinx-linux-gnueabi-

去掉openssl路径下的Makefile的-m64选项,

$ sed -i "s/-m64//g" Makefile

编译,

$ make
$ make install

生成的文件,nginx应用在sbin下,大小为6MB,

zc@ubuntu:~/fdk_develop$ ls -l package/nginx-1.14.2/zynq-static-2015.2.1/
total 16
drwxrwxr-x 2 zc zc 4096 Apr 26 09:37 conf
drwxr-xr-x 2 zc zc 4096 Apr 26 09:37 html
drwxrwxr-x 2 zc zc 4096 Apr 26 09:37 logs
drwxrwxr-x 2 zc zc 4096 Apr 26 09:37 sbin

错误

armv7,

nginx: [emerg] "worker_processes" directive invalid value in /usr/nginx/conf

运行

命令列表,

root@zynqmp:~# ./nginx/sbin/nginx -h
nginx version: nginx/1.14.2
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /home/zc/fdk_develop/package/nginx-1.14.2/zynqmp-static-2018.2/)
  -c filename   : set configuration file (default: conf/nginx.conf)
  -g directives : set global directives out of configuration file

嵌入式平台不能用start来启动nginx,下面这种方法也不会阻塞终端,

root@zynqmp:~/nginx# ./sbin/nginx -p .
root@zynqmp:~/nginx# ps
PID   USER     TIME   COMMAND
...
 2118 root       0:00 nginx: master process ./sbin/nginx -p .
 2119 nobody     0:00 nginx: worker process
 2120 root       0:00 ps

运行之后产生了若干temp文件夹,

root@zynqmp:~/nginx# ls -l
total 36
drwx------    2 nobody   root          4096 Jan 26 12:12 client_body_temp
drwxrwxr-x    2 1000     1000          4096 Jan 26 12:48 conf
drwx------    2 nobody   root          4096 Jan 26 12:12 fastcgi_temp
drwxr-xr-x    2 1000     1000          4096 Jan 26 12:48 html
drwxrwxr-x    2 1000     1000          4096 Apr 28  2019 logs
drwx------    2 nobody   root          4096 Jan 26 12:12 proxy_temp
drwxrwxr-x    2 1000     1000          4096 Jan 26 12:48 sbin
drwx------    2 nobody   root          4096 Jan 26 12:12 scgi_temp
drwx------    2 nobody   root          4096 Jan 26 12:12 uwsgi_temp

通过reload重新加载配置文件,

root@zynqmp:~# ./nginx/sbin/nginx -p ./nginx -s reload
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

三遍猪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值