交叉编译nginx
1 在安装nginx之前,首先先装pcre
# CC=arm-hisiv200-linux-gcc CXX=arm-hisiv200-linux-g++ ./configure --prefix=/usr/local/pcre --host=arm-linux
# make
# make install
2 安装nginx
2.1 先到nginx官网下载对应版本的软件包
我下载的是nginx-1.8.1.tar.gz
2.2 将压缩包解压到任意目录(我的是/user/)得到文件夹nginx-1.8.1
2.3 打开控制台,cd进入nginx-1.8.1目录
2.4 打补丁
2.4.1 补丁a:nginx-1.0.15\auto\cc\conf
case $NGX_CC_NAME in
arm-linux-gcc)
# Modify By XinTinG
# gcc 2.7.2.3, 2.8.1, 2.95.4, egcs-1.1.2
2.4.2 补丁b-1:nginx-1.0.15\auto\types\sizeof
----------------------------------------
checking for $ngx_type size
END
## Modify By XinTinG
ngx_size=4
2.4.3 补丁b-2:nginx-1.0.15\auto\types\sizeof
## Modify By XinTinG
##ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
ngx_test="gcc $CC_TEST_FLAGS $CC_AUX_FLAGS \
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
##eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
##if [ -x $NGX_AUTOTEST ]; then
## ngx_size= `$NGX_AUTOTEST`
## echo " $ngx_size bytes"
##fi
2.4.4 补丁c:nginx-1.0.15\auto\feature
yes)
# /bin/sh is used to intercept "Killed" or "Abort trap" messages
##if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
echo " found"
ngx_found=yes
if test -n "$ngx_feature_name"; then
have=$ngx_have_feature . auto/have
fi
## Modify By XinTinG
##else
## echo " found but is not working"
##fi
;;
2.4.5 补丁d:nginx-1.0.15\configure
if test -z "$NGX_PLATFORM"; then
echo "checking for OS"
##NGX_SYSTEM=`uname -s 2>/dev/null` ## Modify By XinTinG
##NGX_RELEASE=`uname -r 2>/dev/null`
##NGX_MACHINE= "arm" ##`uname -m 2>/dev/null`
2.4.6 补丁e:nginx-1.0.15\src\os\unix\ngx_time.h
#include <time.h> // Modify By XinTinG
#include <ngx_config.h>
#include <ngx_core.h>
2.4.7 补丁f:nginx-1.0.15\src\os\unix\ngx_errno.h
#define NGX_ECANCELED ECANCELED
#define NGX_EILSEQ EILSEQ
#define NGX_ENOMOREFILES 0
#define NGX_SYS_NERR 1
2.5 配置nginx-1.8.1。执行命令:
#CC=arm-hisiv200-linux-gcc ./configure --prefix=/user/nginx --with-pcre=/usr/local/pcre -- host=arm-linux --without-zlib --without-bzip2
2.6 编译nginx,执行命令:
# make
2.7 安装nginx,执行命令:
#make install
就可以在/user/nginx查看到四个文件
如果你做到这里只能说明你才成功一半!
3.问题集:
1)问题:
当你移植nginx到开发板之后,执行 ./sbin/nginx -c conf/nginx.conf 以后会出现如下错误:
getpwnam("**") failed(2:Unknown error)
原因:
在执行getpwnam的时候,系统找不到对应的库文件libness_file.so,然后我根据网上说的去查看了下nginx的动态库,果然如此,确实这个库文件,然后把这个动态库文件拷贝到开发板的/lib下在测试
关于这个动态库请参考: http://www.jollen.org/blog/2006/10/library_dependency_1.html
参考文档: http://blog.chinaunix.net/uid-20543672-id-94317.html
posted on 2016-04-07 21:17 code_development 阅读(855) 评论(0) 编辑 收藏 举报