现在的位置: 首页 > 综合 > 正文

appweb移植到2410

2013年09月10日 ⁄ 综合 ⁄ 共 4574字 ⁄ 字号 评论关闭

在众多的web server中有许多轻量级的web server,如boa , thttp,
lighttpd等,但如果要有较高的安全性和能为后期的web开发开发提供便利的嵌入式web服务器,上面提到的几个web
server显得太单薄了.公司要求用web来管理开发的嵌入式产品,并且要有一定的安全性能.综合比较了大几款轻量级,嵌入式web
server.最后推荐都是由Michael O'Brien架构的两个web服务器:goahead 
 (http://webserver.goahead.com/webserver/webserver.htm
)和appweb(http://www.appwebserver.org/downloads/appWeb/download.php
).

  
    
 其中前者是GoAhead公司的Embedded Management
Framework产品的一部分,这个软件包主要用于解决未来嵌入式系统开发的相关问题,这款WEB服务器非常小巧,它的WIN
CE版本编译后的大小还不到60k,它的输出通常也是面向一些小屏幕设备。GPL & Commercial
License.号称要做成未来嵌入式web server的领头羊.

 
   后者是Michael
O'Brien创立的Mbedthis公司的第一个产品,GPL & Commercial
License.其中MOB本人将其描述为mini-apache.在使用的过程中,确实也感觉到了这点:通过appweb.conf
这个配置文件能支持模块的动态加载.网上讨论说上面两款是大多数路由器等设备web server的首选,下面贴上这两款web
server的主要特性:

 
   appweb
features(懒得翻译):

AppWeb is a standards-based embedded HTTP server that has a wealth
of features including:
1,Standards compliant HTTP/1.1 web server core
2,Embeddable in applications and devices (supports XIP)
3,Dynamically loadable modules
4,Embedded Server Pages (ESP) for dynamic content 
 (其实是为了支持像goahead上的ASP模块而换的一种称呼)
5,Session state data management
6,Server-side Embedded JavaScript
7,Secure Socket Layer (SSL) : 
  
  
   (OpenSSL和MatrixSsl)

8,In-process CGI as well as traditional CGI
9,ROMable web pages and configuration files
10,Digest Authentication 
  
  
  
  
 ********
11,HTTP Client program and library
12,Extensive logging
13,Fastest performance in its class
14,Modular source code and documentation provided
15,Apache-style configuration, logging, and single- and
multi-threaded apps.

 
 因为公司公司的产品要考虑安全性问题,这里得指出matrixssl这个ssl
3.0实现.Matrixssl是专为嵌入式产品开发的一个SSL,比openssl远远要小,GPL &
Commercial License,占用 50K RAM左右。

在性能方面,使用一颗24MH
z的68040处理器,它的响应速度为20次/秒,使用266MHz的Pentium处理器可以达到50次/秒的响应速度。其具有以下特性:

1,支持ASP
2,支持嵌入式的JavaScript
3,标准的CGI执行
4,内存中的CGI处理GoFroms
5,扩展的API
6,快速响应,每秒可处理超过50个请求
7,完全和标准兼容
8, 如果不包含SSL,仅要求60K的内存;包含SSL,要求500K内存
9, web页面可以存在ROM或文件系统中
10,支持多种操作系统,包括eCos 、LINUX 、LynxOS 、QNX 、VxWorks 、WinCE、pSOS等

 
   看了dglwx

在linux时代的静态编译web server
Appweb(带Matrixssl支持) For ARM9+ linux

得到了很多的帮助,现在说说我的移植过程

我的开发环境linux2.6.14+arm2410(板子)

电脑:fedora8 交叉编译器3.4.1

1,下载appweb源代码:    http://www.appwebserver.org/software/appweb-src-2.4.0-0.tar.gz

2,解压:
#tar -xvzf appwe-src-2.4.0-0.tar.gz

3,修改环境变量:

#export CC=/usr/local/arm/3.4.1/bin/arm-linux-gcc
#export AR=/usr/local/arm/3.4.1/bin/arm-linux-ar
#export LD=/usr/local/arm/3.4.1/bin/arm-linux-ld
#export RANLIB=/usr/local/arm/3.4.1/bin/arm-linux-ranlib
#export STRIP=/usr/local/arm/3.4.1/bin/arm-linux-strip
#export CC_FOR_BUILD=gcc

4,下载matrixssl源代码:   http://www.matrixssl.org/download.html

5,解压到/root/wangyi/下:
#tar-xvzf matrixssl-1-8-3-open.tar.gz
6,进入/root/wangyi/src/matrixssl-1-8-3-open/src下修改Makefile:

修改CC,STRIP,AR,RANLIB为我们的交叉编译器,如:
CC =
/opt/crosstool/gcc-3.4.1-glibc-2.3.3/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc

7,make
此时会在当前目录下生成动态链接库libmatrixssl.so和静态链接库libmatrixsslstatic.a这在下面一步配置和编译Appweb时将会用到.

8,对appweb进行./configure:
./configure --host=arm-s3c2410-linux --build=i686-pc-linux
--port=80 --type=RELEASE --disable-log --enable-multi-thread
--disable-shared --disable-samples --disable-shared-libc
--enable-static --disable-test --disable-access-log --enable-ejs
--disable-modules --with-cgi=builtin --with-copy=builtin
--with-auth=builtin --with-esp=builtin --with-upload=builtin
--with-c-api=builtin --without-php5 --with-ssl=builtin
--with-matrixssl=builtin
--with-matrixssl-dir=/root/wangyi/matrixssl-1-8-6-open/src
--with-matrixssl-libpath=/root/wangyi/matrixssl-1-8-6-open/src
--with-matrixssl-iflags="-I /root/wangyi/matrixssl-1-8-6-open/src
-I /root/wangyi/matrixssl-1-8-6-open/"
--with-matrixssl-libs=libmatrixsslstatic

可以通过./configure–-help查看相关说明.关于—with-matrixssl-libs需要说明:这个选项是告诉链接器,在生成
appweb可执行文件时链接哪matrixssl一个lib库.如果想动态编译的话,那么我们就选择libmatrixssl.so这个库,此时我们应
该指定withmatrixssllibs=libmatrixssl;
如果想静态编译的话,我们就应该选择libmatrixsslstatic.a这个静态库文件.此时应该指定
--with-matrixssl-libs=libmatrixsslstatic.

 

9 make

在此过程中会出现matrixssl源代码下的src/os/linux.c中的3个函数未定义错误,此时我们将相关部分注释掉就OK了.

line 123: pthread_mutexattr_init()
line 125 pthread_mutexattr_settype();
line 135 pthread_mutexattr_destroy()

make成功后,将在当appweb目录下生成appweb和appweb.conf文件.另外,里面还有一些matrixssl运行需要的一些Key.这些文件有:appweb(bin)
,appweb.conf(配置文件) ,mime.types
,目录web(DocumentRoot),server.key.pem,server.crt,server.key
10 运行appweb,开启web服务

./appweb -f appweb.conf

在浏览器中输入https://192.168.2.16:4443/
可是不能访问cgi,但可以访问html。。。。

提示是:[root@GlobalTime appweb]$./appweb -f appweb.conf
Unknown conditional OPENSSL_MODULE
Can't make temp file /tmp/MPR_920_127.tmp, errno 30
Can't create stdio files

Can't open CGI output files
502 "Bad Gateway" for "/cgi-bin/Login.cgi", file
"/mnt/bin/appweb/www/cgi-bin/Lo
gin.cgi": Cant write to CGI program

原来他是要在/tmp下写一个super,而我的那个目录是只读的。在源代码中修改:

you can edit mpr/embedded.cpp and change
mprMakeTempFileName and change /tmp to whatever you
need.这是代码开发者给我的建议。。我把/tmp换成了/mnt。

好了这样就ok了

抱歉!评论已关闭.