免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 20214 | 回复: 16

[WebServer] 静态编译web server Appweb(带Matrixssl支持) For ARM9+ linux [复制链接]

论坛徽章:
0
发表于 2008-01-24 20:51 |显示全部楼层
在众多的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等


    由于goahead要求在使用它时,需在主页注明用的是goahead,觉得这点不是很好,就主要做了appweb的移植.可能是国人用它比较少,只看到一个帖子.参考了一下,还是出现了许多问题,另外也没有支持SSL.之后自己看英文文档,在appweb的论坛上看相关的问题,最后终于解决了一大堆疑惑,成功移植到了at91rm9200dk+linux上.为避免后来人走弯路,难得的一次原作,今天就把它晾在着了.个人觉得应该是比较详细了.

注: 环境为Cent OS 4.4 {kernel version:2.6.9-42.EL ,gcc version: 3.4.6 (Red Hat 3.4.6-3)}
      Crosstool:  arm-softfloat-linux-gnu-gcc  gcc-3.4.1-glibc-2.3.3  

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 -C /usr/local/src

3,修改环境变量:

修改CCAR LD RANLIB STRIP为交叉编译环工具;
修改CC_FOR_BUILD为PC的gcc:

编写shell脚本export.sh如下:

#!/bin/bash

exportCC="/opt/crosstool/gcc-3.4.1-glibc-2.3.3/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc"
exportAR="/opt/crosstool/gcc-3.4.1-glibc-2.3.3/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-ar"
exportLD="/opt/crosstool/gcc-3.4.1-glibc-2.3.3/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-ld"
exportRANLIB="/opt/crosstool/gcc-3.4.1-glibc-2.3.3/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-ranlib"
exportSTRIP="/opt/crosstool/gcc-3.4.1-glibc-2.3.3/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-strip"
exportCC_FOR_BUILD="gcc"
echo"@ done!"

#source export.sh或 . export.sh 运行shell脚本并使它生效.


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

5,解压到/usr/local下:
#tar-xvzf matrixssl-1-8-3-open.tar.gz -C /usr/local

6,进入/usr/local/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:
#cd/usr/local/src/appweb-src-2.4.0

#./configure--host=arm-atmel-linux --build=i686-pc-linux --port=80 --type=RELEASE--disable-log --disable-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 --without-c-api--without-php5 --with-ssl=builtin --with-matrixssl=builtin--with-matrixssl-dir=/usr/local/matrixssl/src--with-matrixssl-libpath=/usr/local/matrixssl/src--with-matrixssl-iflags="-I /usr/local/matrixssl/src "--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.

mkdir /usr/local/nfs 建立nfs服务工作目录,并将appweb运行需要的文件放到此目录下:
这些文件有:appweb(bin) ,appweb.conf(配置文件) ,mime.types ,目录web(DocumentRoot),server.key.pem,server.crt,server.key


10 开启NFS服务:

修改/etc/exports文件内容如下:
/usr/local/nfs *(rw,sync,root_squash)

#service protmap start

#service nfs start

#showmount -a 查看共享和访问的目录

开发上板上挂载NFS(确定开发的IP地址和主机地址在同一个网段内):

#mkdir /tmp/nfs

#mount -t nfs hostip:/usr/local/nfs


11 运行appweb,开启web服务

./appweb -f appweb.conf

如果出现错误,按出错信息修改appweb.conf配置文件.


在PC上访问appweb提供的web服务,在firefox下输入目标板的IP地址和端口号
http://10.78.28.218:80/
https://10.78.28.218:4443/

如不能成功访问,需要修改appweb.conf配置文件.

PS:
appweb和goahead首席架构师,Mbedthis公司创始人后来在appweb的论坛上.指出了那被我注释掉的三个函数:

If you build matrixssl with multithreading, then you need to build appweb with multithreading. I would not recommend just commenting out those pthread lines.

Regarding linking statically, you are right to use a static version of the matrix ssl library.

Michael


所以,我们只需要在配置appweb时选上--with--multi-thread就可以了解决三个函数未定义的问题了.
后来Michael又补充道:
Those APIs are part of pthreads the Linux multithreaded library. They are NOT part of appweb.

[ 本帖最后由 dglwx 于 2008-1-24 21:59 编辑 ]

评分

参与人数 1可用积分 +15 收起 理由
bitmilong + 15 精品文章

查看全部评分

论坛徽章:
0
发表于 2008-03-06 13:41 |显示全部楼层

有问题

大侠,我用的PC版本是ubuntu7.04,交叉编译器为arm-linux-gcc-3.4.1。我按照你的方法来在appweb上应用matrixssl编译不过去啊!我已经生成了Matrixssl的动态链接库和静态库,但是在./configure之后还是在matrixSslModule.cpp中有许多未定义的错误,在AppWeb的论坛上也逛了一遍,没有发现什么地方有错误,在此贴出我的configure:
#./configure --host=arm-s3c2440-linux --build=i686-pc-linux --port=80 --type=RELEASE --disable-log --disable-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 --without-c-api --without-php5 --with-ssl=builtin --with-matrixssl=builtin --with-matrixssl-dir=/home/tequlia/tequlia_paper/appweb+matrixssl/matrixssl/src --with-matrixssl-libpath=/home/tequlia/tequlia_paper/appweb+matrixssl/matrixssl/src --with-matrixssl-iflags="-I /home/tequlia/tequlia_paper/appweb+matrixssl/matrixssl/src " --with-matrixssl-libs=libmatrixsslstatic

错误信息:
n file included from matrixSslModule.cpp:40:
matrixSslModule.h:50:24: matrixSsl.h: No such file or directory
In file included from matrixSslModule.cpp:40:
matrixSslModule.h:91: error: ISO C++ forbids declaration of `sslKeys_t' with no type
matrixSslModule.h:91: error: expected `;' before '*' token
matrixSslModule.h:108: error: ISO C++ forbids declaration of `ssl_t' with no type
matrixSslModule.h:108: error: expected `;' before '*' token
matrixSslModule.h:109: error: `sslBuf_t' does not name a type
matrixSslModule.h:110: error: `sslBuf_t' does not name a type
matrixSslModule.h:111: error: `sslBuf_t' does not name a type
matrixSslModule.cpp: In member function `virtual int MaMatrixSslModule::start()':
matrixSslModule.cpp:94: error: `matrixSslOpen' undeclared (first use this function)
matrixSslModule.cpp:94: error: (Each undeclared identifier is reported only once for each function it appears in.)
matrixSslModule.cpp: In member function `virtual void MaMatrixSslModule::stop()':
matrixSslModule.cpp:110: error: `matrixSslClose' undeclared (first use this function)
matrixSslModule.cpp: In constructor `MaMatrixSslConfig::MaMatrixSslConfig(MaHost*)':
matrixSslModule.cpp:147: error: `keys' undeclared (first use this function)
matrixSslModule.cpp: In member function `virtual int MaMatrixSslConfig::start()':
matrixSslModule.cpp:201: error: `keys' undeclared (first use this function)
matrixSslModule.cpp:201: error: `matrixSslReadKeys' undeclared (first use this function)
matrixSslModule.cpp: In member function `virtual void MaMatrixSslConfig::stop()':
matrixSslModule.cpp:242: error: `keys' undeclared (first use this function)
matrixSslModule.cpp:243: error: `matrixSslFreeKeys' undeclared (first use this function)
matrixSslModule.cpp: In constructor `MaMatrixSslSocket::MaMatrixSslSocket(MaMatrixSslConfig*)':
matrixSslModule.cpp:258: error: `ssl' undeclared (first use this function)
matrixSslModule.cpp:259: error: `insock' undeclared (first use this function)
matrixSslModule.cpp:260: error: `outsock' undeclared (first use this function)
matrixSslModule.cpp:261: error: `inbuf' undeclared (first use this function)
matrixSslModule.cpp: In member function `virtual int MaMatrixSslSocket::initConnection()':
matrixSslModule.cpp:299: error: `ssl' undeclared (first use this function)
matrixSslModule.cpp:308: error: 'class MaMatrixSslConfig' has no member named 'keys'
matrixSslModule.cpp:309: error: `SSL_FLAGS_SERVER' undeclared (first use this function)
matrixSslModule.cpp:309: error: `matrixSslNewSession' undeclared (first use this function)
matrixSslModule.cpp:321: error: `insock' undeclared (first use this function)
matrixSslModule.cpp:323: error: `outsock' undeclared (first use this function)
matrixSslModule.cpp:325: error: `inbuf' undeclared (first use this function)
matrixSslModule.cpp: In member function `virtual bool MaMatrixSslSocket::dispose()':
matrixSslModule.cpp:339: error: `ssl' undeclared (first use this function)
matrixSslModule.cpp:340: error: `matrixSslDeleteSession' undeclared (first use this function)
matrixSslModule.cpp:342: error: `insock' undeclared (first use this function)
matrixSslModule.cpp:343: error: `outsock' undeclared (first use this function)
matrixSslModule.cpp:344: error: `inbuf' undeclared (first use this function)
matrixSslModule.cpp: In member function `virtual void MaMatrixSslSocket::close(int)':
matrixSslModule.cpp:359: error: `ssl' undeclared (first use this function)
matrixSslModule.cpp:360: error: `outsock' undeclared (first use this function)
matrixSslModule.cpp:360: error: `matrixSslEncodeClosureAlert' undeclared (first use this function)
matrixSslModule.cpp: In member function `virtual int MaMatrixSslSocket::write(char*, int)':
matrixSslModule.cpp:394: error: `SSL_MAX_PLAINTEXT_LEN' undeclared (first use this function)
matrixSslModule.cpp:401: error: `outsock' undeclared (first use this function)
matrixSslModule.cpp:427: error: `ssl' undeclared (first use this function)
matrixSslModule.cpp:427: error: `matrixSslEncode' undeclared (first use this function)
matrixSslModule.cpp:429: error: `SSL_ERROR' undeclared (first use this function)
matrixSslModule.cpp:431: error: `SSL_FULL' undeclared (first use this function)
matrixSslModule.cpp:432: error: `SSL_MAX_BUF_SIZE' undeclared (first use this function)
matrixSslModule.cpp: In member function `virtual int MaMatrixSslSocket::read(char*, int)':
matrixSslModule.cpp:521: error: `ssl' undeclared (first use this function)
matrixSslModule.cpp:532: error: `inbuf' undeclared (first use this function)
matrixSslModule.cpp:546: error: `insock' undeclared (first use this function)
matrixSslModule.cpp:594: error: `matrixSslDecode' undeclared (first use this function)
matrixSslModule.cpp:601: error: `SSL_SUCCESS' undeclared (first use this function)
matrixSslModule.cpp:611: error: `SSL_PROCESS_DATA' undeclared (first use this function)
matrixSslModule.cpp:629: error: `SSL_SEND_RESPONSE' undeclared (first use this function)
matrixSslModule.cpp:660: error: `SSL_ERROR' undeclared (first use this function)
matrixSslModule.cpp:673: error: `SSL_ALERT' undeclared (first use this function)
matrixSslModule.cpp:674: error: `SSL_ALERT_CLOSE_NOTIFY' undeclared (first use this function)
matrixSslModule.cpp:686: error: `SSL_PARTIAL' undeclared (first use this function)
matrixSslModule.cpp:689: error: `SSL_MAX_BUF_SIZE' undeclared (first use this function)
matrixSslModule.cpp:710: error: `SSL_FULL' undeclared (first use this function)
make[4]: *** [../../../obj/arm-s3c2440-linux/matrixSslModule.o] 错误 1
make[3]: *** [compileAdirs] 错误 2
make[2]: *** [compileDirs] 错误 2
make[1]: *** [compileDirs] 错误 2
make: *** [compile] 错误 2

论坛徽章:
3
CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52
发表于 2008-03-06 16:16 |显示全部楼层
关注中……

论坛徽章:
0
发表于 2008-03-07 04:08 |显示全部楼层
学习一下~~:wink:

论坛徽章:
0
发表于 2008-03-08 16:21 |显示全部楼层
移植做了两三个月了,现在手头上也没有matrixssl源码。根据上面的错误信息提示是编译的时候找不到matrixSsl.h这个头文件,而这个头文件好像是在matrixssl/src,所以我们通过--with-matrixssl-iflags来告诉它到这里找这个头文件。
--with-matrixssl-iflags="-I/home/tequlia/tequlia_paper/appweb+matrixssl/matrixssl/src "

如果不是这个问题,你可以在matrixssl源码里找找看这个头文件在哪里,然后ln -s 到matrixssl/src

Please tell me whether you have make it. Good Luck!

[ 本帖最后由 dglwx 于 2008-11-26 08:57 编辑 ]

评分

参与人数 1可用积分 +15 收起 理由
bitmilong + 15 鼓励多回帖

查看全部评分

论坛徽章:
0
发表于 2008-03-12 14:26 |显示全部楼层
我们用的goahead觉得比较不错,不过你说的这个我也要学习一下

论坛徽章:
0
发表于 2008-03-17 17:20 |显示全部楼层
今天又做了一次移植,其实只改这一处就行了:
--with-matrixssl-iflags="-I/home/tequlia/tequlia_paper/appweb+matrixssl/matrixssl/src -I/home/tequlia/tequlia_paper/appweb+matrixssl/matrixssl"

   你所需要两个的头文件就在/home/tequlia/tequlia_paper/appweb+matrixssl/matrixssl目录下,我们只需将这个路径也指定就行了.

论坛徽章:
0
发表于 2008-03-19 14:15 |显示全部楼层
呵呵,早就搞定了,不是你的问题,是我在设定路径参数的时候,设置的路径不对,又改了一下,OK了。我用OpenSSL做了一个第三方认证,交换证书的时候好像有点问题。我用firefox做https测试比较快,但是用IE的时候反应就是慢了很多。why?

论坛徽章:
0
发表于 2008-03-22 15:16 |显示全部楼层
这个我倒没问题,在处理SSL时,firefox和IE上都很快.只是apweb的Digest Authentication有问题, 那是IE6.0的一个bug,IE7.0解决了的.

    有人在站内信理提到如何做底层硬件的接口显示, 其实在appweb中很简单,他有一中机制能够是上层的JavaScript(具体说应该是EJS:Embedded JavaScript)能带参数调用我们的底层C函数,底层的C函数可以返回多个参数,这主要通过MprVar定义的对象返回多个值.具体可以参考文档中的C和C++函数参考,以及samples/C+下的simpleModule.cpp以及samples/C/ESP下的simpleESP.c 这两个文件.以及他的动态模块加载技术. 总的来说,多看他的那个doc.

[ 本帖最后由 dglwx 于 2008-3-22 15:23 编辑 ]

论坛徽章:
0
发表于 2008-03-22 18:42 |显示全部楼层
有没有人用mathopd??
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP