Nginx在嵌入式系统中应用(ARM处理器)

本文作为老技术人对国庆(2014.10.01)的献礼,有限开放,属于本工作室5A级保密文件,不提供技术咨询:

Nginx(“Engine X”)作为世界第三大Web服务器,如果能应用到嵌入式系统中应用中是多么美好的事情,如下将告诉你实现的可能, 实现(通过验证)最小硬件配置(300Mhz ARM9,128MB内存)。

交叉编译PCRE库 ,,Nginx对PCRE库有依赖,PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 Perl 兼容的 正则表达式 库。这些在执行正规表达式模式匹配时用与Perl 5同样的语法和语义是很有用的。

下载: pcre-8.30.tar.bz2 (参考放置路劲:/home/fqheda/XT-linux/LXT5/Eweb/eweb-v3.0.3/)

tar -jxvf pcre-8.30.tar.bz2

chmod -Rf 777 pcre-8.30

cd pcre-8.30

./configure CC=arm-linux-gcc –host=arm-linux –prefix=/home/nginx

make

make install

2. 交叉编译Nginx,Nginx不多做解释,假设你懂的。

下载: nginx-1.0.15.tar.gz (参考放置路劲:/home/fqheda/XT-linux/LXT5/Eweb/eweb-v3.0.3/)

tar -zxvf nginx-1.0.15.tar.gz

chmod -Rf 777 nginx-1.0.15 cd nginx-1.0.15

打补丁:

补丁a: ginx-1.0.15\auto\cc\conf

case $NGX_CC_NAME in

arm-linux-gcc)

Modify By XinTinGgcc 2.7.2.3, 2.8.1, 2.95.4, egcs-1.1.2

补丁b-1: nginx-1.0.15\auto\types\sizeof

checking for $ngx_type size

END

Modify By XinTinG

ngx_size=4

补丁b-2: nginx-1.0.15\auto\types\sizeof

Modify By XinTinGngx_test=”CC_TEST_FLAGS $CC_AUX_FLAGS \

ngx_test=”gcc CC_AUX_FLAGS \

-o ngx_feature_libs”

eval “NGX_AUTOCONF_ERR 2>&1”if [ -x $NGX_AUTOTEST ]; thenngx_size= $NGX_AUTOTESTecho ” $ngx_size bytes”fi

补丁c: nginx-1.0.15\auto\feature

yes)

/bin/sh is used to intercept “Killed” or “Abort trap” messagesif /bin/sh -c 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 XinTinGelseecho ” found but is not working”fi

;;

补丁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 XinTinGNGX_RELEASE=uname -r 2>/dev/nullNGX_MACHINE= “arm” ##uname -m 2>/dev/null

补丁e: nginx-1.0.15\src\os\unix\ngx_time.h

include include include define NGX_ECANCELEDECANCELEDdefine NGX_EILSEQEILSEQdefine NGX_ENOMOREFILES 0define NGX_SYS_NERR1// Modify By XinTinG 交叉编译:

export CC=arm-linux-gcc

export LD=arm-linux-ld

export AR=arm-linux-ar

export NGX_SYSTEM=linux

export NGX_RELEASE=3.2-XT5

export NGX_MACHINE=arm

cd nginx-1.0.15

make clean

./configure –with-google_perftools_module –with-http_stub_status_module –prefix=/home/nginx –with-pcre=/home/fqheda/XT-linux/LXT5/Eweb/eweb-v3.0.3/pcre-8.30 –with-cc-opt=”-O2 -Wall -Wpointer-arith -I/home/nginx/include” –with-ld-opt=”-L/home/nginx/lib”

make CPU=arm

make install

打安装包:

cd /home

tar -jcvf nginx.tar.bz2 ngin x

安装运行Nginx (ARM板开发平台)

nginx.tar.bz2 解压到arm板linux shell控制台中home文件夹;

定向nginx动态库位置 : export LD_LIBRARY_PATH=/home/nginx/lib:$LD_LIBRARY_PATH

启动nginx : /home/nginx/sbin/nginx -c /home/nginx/conf/nginx.conf

注:测试()前,请认真理解配置文件nginx.conf(可能需要修改),本移植已在全国各地近千台嵌入式设备上良好运行(相当于每台设备安装了一个小型网站),不要轻易怀疑移植的正确性!

(作者 冯青华 信庭嵌入式工作室()- CEO ) <转载请注名来路>

悠然享受和大自然融合之乐。

Nginx在嵌入式系统中应用(ARM处理器)

相关文章:

你感兴趣的文章:

标签云: