Arm-Linux 移植 Nginx
有关博客:
《Windows 编译安装 nginx 服务器 + rtmp 模块》、《Ubuntu 编译安装 nginx》、《Arm-Linux 移植 Nginx》
前言:
基本思路:由于nginx在嵌入式下的支持不是很好,所以在配置编译之前,需要手动修改工程中的某些项目。
注意:这个和以往的交叉编译不一样,nginx的交叉编译依赖的库都是源码包,而不是最终的结果。
主机要做的事情:
## # Copyright By Schips, All Rights Reserved # https://gitee.com/schips/ # File Name: make.sh # Created : Fri Nov :: AM CST ## #!/bin/sh BASE=`pwd` BUILD_HOST=arm-hisiv500-linux ZLIB=zlib- OPENSSL=openssl-1.0.2t PCRE=pcre-8.30 NGINX=nginx- FIN_INSTALL=/usr/${NGINX} make_dirs() { cd ${BASE} mkdir compressed install source -p } download_package () { cd ${BASE}/compressed #下载包 wget -c https://www.zlib.net/${ZLIB}.tar.gz wget https://www.openssl.org/source/${OPENSSL}.tar.gz # 注意地址 wget -c https://jaist.dl.sourceforge.net/project/pcre/pcre/8.30/${PCRE}.tar.bz2 wget -c http://mirrors.sohu.com/nginx/${NGINX}.tar.gz } tar_package () { cd ${BASE}/compressed ls * > /tmp/list.txt for TAR in `cat /tmp/list.txt` do tar -xf $TAR -C ../source done rm -rf /tmp/list.txt } pre_configure_nginx () { cd ${BASE}/source/${NGINX} # auto/cc/name sed -r -i "/ngx_feature_run=yes/ s/.*/\tngx_feature_run=no/g" auto/cc/name sed -r -i "/exit 1/ s/.*//1" auto/cc/name # auto/types/sizeof sed -r -i "/ngx_size=`$NGX_AUTOTEST`/ s/.*/\tngx_size=4/g" auto/types/sizeof # sed -r -i "/PCRE_CONF_OPT=/ s/.*/PCRE_CONF_OPT=--host=${BUILD_HOST}/g" auto/options } configure_nginx () { cd ${BASE}/source/${NGINX} BUILD=`pwd` ./configure \ --builddir=${BUILD} \ --prefix=${FIN_INSTALL} \ --with-http_mp4_module \ --with-http_ssl_module \ --without-http_upstream_zone_module \ --with-openssl-opt=os/compiler:${BUILD_HOST}-gcc \ --with-cc=${BUILD_HOST}-gcc \ --with-cpp=${BUILD_HOST}-g++ \ --with-ld-opt=-lpthread \ --with-cc-opt='-D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64' \ --with-pcre=${BASE}/source/${PCRE} \ --with-openssl=${BASE}/source/${OPENSSL} \ --with-zlib=${BASE}/source/${ZLIB} \ --with-http_v2_module && echo "${FIN_INSTALL} with ${BUILD_HOST}" > ccinfo } pre_make_nginx () { cd ${BASE}/source/${NGINX} HEAD_FILE=`find . -name "ngx_auto_config.h"` DEL_LINE=`sed -n "/NGX_CONFIGURE/=" ${HEAD_FILE}` sed -i "${DEL_LINE}d" ${HEAD_FILE} echo "#undef NGX_CONFIGURE " >> ${HEAD_FILE} echo "#define NGX_CONFIGURE \"./configure\"" >> ${HEAD_FILE} echo "#ifndef NGX_SYS_NERR" >> ${HEAD_FILE} echo "#define NGX_SYS_NERR 132" >> ${HEAD_FILE} echo "#endif" >> ${HEAD_FILE} echo "#ifndef NGX_HAVE_SYSVSHM" >> ${HEAD_FILE} echo "#define NGX_HAVE_SYSVSHM 1" >> ${HEAD_FILE} echo "#endif" >> ${HEAD_FILE} # 删除makefile 多余的几行 DEL_LINE=`sed -n "/build\:/=" Makefile | awk 'END {print}'` # 因为是有 行,删除以后文件会发生变化 sed -i "${DEL_LINE}d" Makefile sed -i "${DEL_LINE}d" Makefile DEL_LINE=`sed -n "/install\:/=" Makefile | awk 'END {print}'` sed -i "${DEL_LINE}d" Makefile sed -i "${DEL_LINE}d" Makefile DEL_LINE=`sed -n "/modules\:/=" Makefile | awk 'END {print}'` sed -i "${DEL_LINE}d" Makefile sed -i "${DEL_LINE}d" Makefile } make_nginx () { cd ${BASE}/source/${NGINX} make -j4 && sudo make install && sudo mv ccinfo ${FIN_INSTALL}/ccinfo } sudo ls make_dirs #download_package tar_package pre_configure_nginx configure_nginx pre_make_nginx make_nginx
这样应该就没有什么问题了。
arm板子:
/usr/nginx/sbin/nginx -c /usr/nginx/conf/nginx.conf -p usr/nginx #启动nginx
编译nginx时指定外部模块
第三方模块下载地址:https://www.nginx.com/resources/wiki/modules/index.html
使第三方模块的生效方法: /configure --add-module=模块的路径
例如:
/configure --prefix=/usr/local/nginx-1.4.1 \ --with-http_stub_status_module \ --with-http_ssl_module --with-http_realip_module \ --with-http_image_filter_module \ --add-module=../ngx_pagespeed-master
正文到此结束,但为了让读者能够搞清楚脚本中的非常规指令的意义,本人保留了下文,以作为手动修改的参考依据。
nginx根目录下, 执行此脚本,再一步步排查错误。
cd ${BASE}/source/${NGINX} echo ${BASE}/source/${NGINX} BUILD=`pwd` ./configure \ --builddir=${BUILD} \ --prefix=${BASE}/install/nginx \ --with-http_mp4_module \ --with-http_ssl_module \ --without-http_upstream_zone_module \ --with-openssl-opt=os/compiler:${BUILD_HOST}-gcc \ --with-cc=${BUILD_HOST}-gcc \ --with-cpp=${BUILD_HOST}-g++ \ --with-ld-opt=-lpthread \ --with-cc-opt='-D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64' \ --with-pcre=${BASE}/source/${PCRE} \ --with-openssl=${BASE}/source/${OPENSSL} \ --with-zlib=${BASE}/source/${ZLIB} \ --with-http_v2_module
提示
checking for OS + Linux --generic x86_64 checking for C compiler ... found but is not working ./configure: error: C compiler arm-hisiv500-linux-gcc is not found make: *** No rule to make target 'build', needed by 'default'. Stop.
解决方法:
修改 auto/cc/name ngx_feature_run=yesArm-Linux 移植 Nginx的更多相关文章
- arm linux 移植 x265
背景 本来想着把 x265编译到ffmpeg里面,搞定了x265的编译:但是一直报ERROR: x265 not found using pkg-config这个错误,我按照网上的资料,查看了ffbu ...
- Linux 安装 go 以及 arm linux 移植 go
背景 Go是一门全新的静态类型开发语言,具有自动垃圾回收,丰富的内置类型,函数多返回值,错误处理,匿名函数,并发编程,反射等特性. 从Go1.4之后Go语言的编译器完全由Go语言编写,所以为了从源代码 ...
- arm linux 移植 MQTT (paho、mosquitto)
前言 我们在这里做2件事情: 1)编译 paho.mqtt.mosquitto 2个开源项目的c版本库(mosquitto库没有用上) 2)编译好 依赖 paho.mqtt的库编写例程 + mosqu ...
- arm linux 移植 PHP
背景: PHP 是世界上最好的语言. host平台 :Ubuntu 16.04 arm平台 : 3531d arm-gcc :4.9.4 php :7.1.30 zlib :1.2.11 libxml ...
- arm linux 移植 ffmpeg 库 + x264
背景 Ffmpeg 中带有h264的解码,没有编码,需要添加x264.libx264是一个自由的H.264编码库,是x264项目的一部分,使用广泛,ffmpeg的H.264实现就是用的libx264. ...
- arm linux 移植支持 HP打印机
背景 由于业务需要,需要hi3531d主板上加入对于HP打印机的支持. 通过与产品经理,技术主管的沟通:通用支持是不现实的,只要求彩色打印,先不考虑打印机的价格,只要支持一款打印机即可. 注意: Li ...
- arm linux 移植 gdb/gdbserver
背景 调试工具gdb的使用对于嵌入式Linux开发人员来说是一项不可少的技能. 目前,嵌入式 Linux系统中,主要有三种远程调试方法,分别适用于不同场合的调试工作:用ROM Monitor调试目标机 ...
- arm linux 移植 udhcp 与 使用
背景 在一些网络环境下,需要静态IP不够现实,需要使用DHCP进行自动获取IP地址. udhcpc是一个面向嵌入式系统的非常小的DHCP客户端,字母的缩写微μ- DHCP -客户端client(μDH ...
- arm linux 移植 rsync
背景: 在产品开发中可以使用rsync进行大文件的拷贝,断点续传. host平台 :Ubuntu 16.04 arm平台 : 3531d rsync :3.1.3 arm-gcc :4.9.4 ...
- arm linux 移植 jpeg
背景: host平台 :Ubuntu 16.04 arm平台 : S5P6818 jpeg :v9c arm-gcc :4.8.1 主机准备: 运行以下脚本: ## # Copyright By Sc ...
随机推荐
- let
let a=2+2 #+ - * / % ** 都支持 支持类C的计算方式 let i++ let i-- let i+=10 let i-=10 let i*=10 let i/=10 let i% ...
- CSS样式表书写位置
一.内嵌式写法:样式只作用于当前文件,没有真正实现结构表现分离. <head> <style type=”text/css”> 样式表写法 </style> < ...
- 洛谷 P1474 货币系统 Money Systems 题解
P1474 货币系统 Money Systems 题目描述 母牛们不但创建了它们自己的政府而且选择了建立了自己的货币系统.由于它们特殊的思考方式,它们对货币的数值感到好奇. 传统地,一个货币系统是由1 ...
- 2017.10.1 国庆清北 D1T1 zhx的字符串题
题目背景 2017国庆清北D1T1 题目描述 你是能看到第一题的 friends 呢. ——hja 何大爷对字符串十分有研究,于是天天出字符串题虐杀 zhx.何大爷今天为 字符串定义了新的权值计算方法 ...
- nginx重启 平滑重启
进入 ngiinx sbin目录下./nginx -c /usr/local/nginx/conf/nginx.conf -c参数指定了要加载的nginx配置文件路径 停止操作停止操作是通过向ngin ...
- 带状矩阵的存储(c++)
2 1 0 0 3 1 3 0 0 5 2 7 0 0 9 0 这个程序对于三对角矩阵都是有效的,为了精 ...
- SSH框架整合2
===========================================web.xml================================================== ...
- 20189220 余超《Linux内核原理与分析》第八周作业
Linux内核如何装载和启动一个可执行程序 本章知识点 ELF(Executable and Linking Format)是一种对象文件的格式,用于定义不同类型的对象文件(Object files) ...
- coredump之栈溢出
1.栈溢出引发的core往往出现出现在递归调用中. gdb时看到的特征是: 栈缺失,当前栈地址不可读. 根据栈是逆向生长的特点(栈逆向生长,所以很容易出现类似数组溢出覆盖率函数返回地址,导致函数退出地 ...
- JavaScript工具类(三):localStorage本地储存
localStorage Web 存储 API 提供了 sessionStorage (会话存储) 和 localStorage(本地存储)两个存储对象来对网页的数据进行添加.删除.修改.查询操作. ...