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 ...
随机推荐
- 【UVA11134】传说中的车
横纵坐标互不影响,所以问题转化到一维:在n个区间中每个区间选一个数,n个数都被选一次 将区间按右端点排序,枚举区间,每个区间选最靠左的没被选过的点 #include<algorithm> ...
- mysql 自联结
mysql> select * from test; +----+------------+-------+-----------+ | id | name | score | subject ...
- mysql 获取字符串的长度
mysql> select * from test; +----+------------+-------+-----------+ | id | name | score | subject ...
- python安装redis库
pip install redis 没有相应的资源 可以到redisio上找到clients, https://redis.io/clients 如下所示 下图中带黄五角星的为官方推荐的: 下 ...
- rust变量与可变性
fn main() { //let x = 5; let mut x = 5; //通过const定义常量名称要大写,并且值不可更改 const Y:i32=6; println!("Y i ...
- 项目启动tomcat失败的几种可能原因和解决方法
传送门:https://blog.csdn.net/u010565910/article/details/80411468 总结一下tomcat启动问题,也给自己做个笔记 , 逐渐补充完善. 1.ja ...
- sip user Authentication and 401
https://www.vocal.com/sip-2/sip-user-authentication/ https://tools.ietf.org/html/rfc3261 SIP User Au ...
- AudioManager: android插上耳机仍然使用扬声器播放音频
手机音频的输出有外放(Speaker).听筒(Telephone Receiver).有线耳机(WiredHeadset).蓝牙音箱(Bluetooth A2DP)等输出设备.在平时,电话免提.插拔耳 ...
- Vintage、滚动率、迁移率的应用
python信用评分卡建模(附代码,博主录制) https://study.163.com/course/introduction.htm?courseId=1005214003&utm_ca ...
- PHP 发送 POST 值到任意 url
以下方法可以实现将 POST 值发送到 url,并获取返回值 $url = 'http://www.someurl.com'; $myvars = 'myvar1=' . $myvar1 . '&am ...