歡迎您光臨本站 登入註冊首頁

概述

   在眾多的webserver中有許多輕量級的webserver,如boa,thttp,lighttpd等,但如果要有較高的安全性和能為後期的web開發開發提供便利的嵌……

    在眾多的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的論壇上.指出了那被我註釋掉的三個函數:
QUOTE:
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又補充道:
QUOTE:
Those APIs are part of pthreads the Linux multithreaded library. They are NOT part of appweb.


[admin via 研發互助社區 ] 靜態編譯web server Appweb(帶Matrixssl支持) For ARM9、linux已經有6758次圍觀

http://cocdig.com/docs/show-post-42071.html