下载地址:
1.
2.
3.
其它版本(老的)的appweb可以从下载
使用环境:
Linux box:CentOS4.4
编译器:arm-linux-gcc 3.3.2
开发板:FS2410
软件版本:openssl-0.9.8a.tar.gz、appweb-src-2.4.2-2.tar.gz、matrixssl-1-8-5-open.tgz
一、一般编译(没有ssl支持)
1.配置如下:
[root@localhost appweb-src-2.4.2]# CC_FOR_BUILD=gcc CC=arm-linux-gcc AR=arm-linux-ar LD=arm-linux-ld STRIP=arm-linux-strip ./configure --host=arm-s3c2410-linux --disable-shared
曾试过用shared但是没有成功,把libappweb.so.2复制到lib或/usr/lib下还是不行,提示找不到库
静态编译出的appweb大约有3.8M,在appweb-src-2.4.2/appweb目录下
2.
把它复制到开发板/usr/sbin目录
然后复制下列文件
[root@localhost sbin]# ls /opt/nfsroot/mnt/etc/appweb/
appweb.conf groups.db server.crt server.key.pem mime.types server.key users.db
3.放置网页文件:
所有的页面放在此目录下,这个可以在/etc/appweb/appweb.conf中修改:/opt/nfsroot/mnt/etc/var/www/appweb-default
4.测试:
~ # appweb &
~ # default:2 main Configuration for Mbedthis Appweb
default:2 main --------------------------------------------
default:2 main Host: localhost
default:2 main CPU: arm
default:2 main OS: LINUX
default:2 main Distribution: unknown Unknown
default:2 main OS: LINUX
default:2 main Version: 2.4.2.2
default:2 main BuildType: DEBUG
default:2 main Started at: Thu Jan 1 00:03:44 1970
default:2 main Log rotation count: 0
default:2 main --------------------------------------------
default:2 main Using server root: /etc/appweb
default:2 main Configuration via Command Line
default:2 main Document Root "/etc/appweb/web"
[1] + Segmentation fault appweb
测试应该指定配置文件,这和在Linux box上不同(好像在PC机上也要指定):
~ # appweb -f appweb.conf &
[1] - Done appweb -f appweb.conf
~ # default:1 main Error: Can't log errors to /var/log/appweb/error.log:2
default:1 main Error: Ignoring bad directive "ErrorLog" at line 22 in /etc/appweb/appweb.conf
default:1 main Error: Bad group name: nobody
default:1 main Error: Missing an SSL Provider
default:1 main Error: Ignoring bad directive "SSLEngine" at line 380 in /etc/appweb/appweb.conf
default:1 main Error: Missing SSLEngine directive
default:1 main Error: Ignoring bad directive "SSLCipherSuite" at line 381 in /etc/appweb/appweb.conf
default:1 main Error: Missing SSLEngine directive
default:1 main Error: Ignoring bad directive "SSLProtocol" at line 382 in /etc/appweb/appweb.conf
default:1 main Error: Missing SSLEngine directive
default:1 main Error: Ignoring bad directive "SSLCertificateFile" at line 387 in /etc/appweb/appweb.conf
default:1 main Error: Missing SSLEngine directive
default:1 main Error: Ignoring bad directive "SSLCertificateKeyFile" at line 393 in /etc/appweb/appweb.conf
default:1 main Error: Can't open log file /var/log/appweb/access.log
出现这些错误是因为编译时的配置问题,大致是可以运行了,在浏览器中输入:就可以访问了。
基本上是可以使用了,如果访问的页面不存在,在终端会有相应的提示。针对上面的错误提示,以后再弄。
另外编译各个文件时会有-mcpu=arm7tdmi这个选项,在网上也没有找到,但不影响运行。
二、添加matrixssl支持
在没有加入ssl支持时访问和显示的是一样的页面,访问 时提示找不到页面,加入ssl后 显示乱码。
访问 和 显示的页面是一样的,这说明ssl在起作用了。
正如上面提到,在没有编译matrix时会出现一些错误,下面介绍如何消除这些错误:
1.交叉编译matrixssl:
[root@localhost sheji]# cd matrixssl-1-8-5-open/src
[root@localhost src]# make CC=arm-linux-gcc AR=arm-linux-ar LD=arm-linux-ld STRIP=arm-linux-strip RANLIB=arm-linux-ranlib
make完成后会生成libmatrixsslstatic.a和libmatrixssl.so两个库文件,这里采用静态编译所以只用到第一个文件。
参考网上文章添加编译选项如下:
[root@localhost appweb-src-2.4.2]# CC_FOR_BUILD=gcc CC=arm-linux-gcc AR=arm-linux-ar LD=arm-linux-ld STRIP=arm-linux-strip ./configure --host=arm-s3c2410-linux --disable-shared --with-ssl=builtin --with-matrixssl=builtin --with-matrixssl-dir=/opt/sheji/matrixssl-1-8-5-open/src --with-matrixssl-libs=/opt/sheji/matrixssl-1-8-5-open/src --with-matrixssl-iflags="-I /opt/sheji/matrixssl-1-8-5-open/src" --with-matrixssl-libs=libmatrixsslstatic
然后make出现找不到头文件错误:
In file included from matrixSslModule.cpp:40:
matrixSslModule.h:50:38: matrixSsl.h: No such file or directory
In file included from matrixSslModule.cpp:40:
matrixSslModule.h:91: error: syntax error before `*' token
matrixSslModule.h:108: error: syntax error before `*' token
matrixSslModule.h:109: error: 'sslBuf_t' is used as a type, but is not defined
as a type.
matrixSslModule.h:110: error: 'sslBuf_t' is used as a type, but is not defined
as a type.
matrixSslModule.h:111: error: 'sslBuf_t' is used as a type, but is not defined
as 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: `matrixSslReadKeys' undeclared (first use this
function)
matrixSslModule.cpp: In member function `virtual void MaMatrixSslConfig::stop()
':
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: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: In member function `virtual bool
MaMatrixSslSocket::dispose()':
matrixSslModule.cpp:340: error: `matrixSslDeleteSession' undeclared (first use
this function)
matrixSslModule.cpp: In member function `virtual void
MaMatrixSslSocket::close(int)':
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: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: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: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)
make[4]: *** [../../../obj/arm-s3c2410-linux/matrixSslModule.o] Error 1
make[3]: *** [compileAdirs] Error 2
make[2]: *** [compileDirs] Error 2
make[1]: *** [compileDirs] Error 2
make: *** [compile] Error 2
提到的头文件在src的上级目录于是修改如下:
[root@localhost appweb-src-2.4.2]# CC_FOR_BUILD=gcc CC=arm-linux-gcc AR=arm-linux-ar LD=arm-linux-ld STRIP=arm-linux-strip ./configure --host=arm-s3c2410-linux --disable-shared --with-ssl=builtin --with-matrixssl=builtin --with-matrixssl-dir=/opt/sheji/matrixssl-1-8-5-open/src --with-matrixssl-libpath=/opt/sheji/matrixssl-1-8-5-open/src --with-matrixssl-iflags="-I /opt/sheji/matrixssl-1-8-5-open" --with-matrixssl-libs=libmatrixsslstatic
这样就可以了,复制appweb目录下appweb到开发板/usr/sbin
~ # appweb -f appweb.conf &
~ # default:1 main Error: Can't log errors to /var/log/appweb/error.log:2
default:1 main Error: Ignoring bad directive "ErrorLog" at line 22 in /etc/appweb/appweb.conf
default:1 main Error: Bad group name: nobody
default:1 main Error: MatrixSSL: Could not read or decode certificate or key file. default:1 main Error: Can't open log file /var/log/appweb/access.log
这是因为当时怀疑配置文件/etc/appweb/appweb.conf中的变量有误,做了一些修改,修改387行和393行的$(SERVER_ROOT)为 $SERVER_ROOT就可以了。
另外,如果已经有一个进程在运行时再运行appweb -f appweb.conf &会出错,因为相应端口号已经被占用:
~ # default:1 main Error: Can't log errors to /var/log/appweb/error.log:2
default:1 main Error: Ignoring bad directive "ErrorLog" at line 22 in /etc/appweb/appweb.conf
default:1 main Error: Bad group name: nobody
default:1 main Error: MatrixSSL: Could not read or decode certificate or key file.
default:1 main Error: Can't open log file /var/log/appweb/access.log
default:1 main Error: Can't open a socket on , port 7777
default:1 main Error: Can't listen for HTTP on :7777
default:1 main Error: Can't start server, exiting.
三、OpenSSL的支持:
相关:在这里openssl目录是我编译好openssl后安装到的目录,如果要生成动态库的话就要修改openssl-0.9.8a目录中的Makefile第18行为:18:SHLIB_TARGET=linux-shared,然后
make && make build-shared 就会生成相应的动态库文件
下面开始为appweb添加openssl支持:
1.首先要修改/opt/sheji/appweb-src-2.4.2/http/modules/openSsl/Makefile文件注释掉61到82行,这几行是用来链接动态库的,在这里我们想把appweb链接成静态的:
61#$(BLD_MOD_DIR)/libcrypto$(BLD_SHLIB): $(BLD_OPENSSL_DIR)/libcrypto$(BLD_SHLIB)
62# cp $(BLD_OPENSSL_DIR)/libcrypto*$(BLD_SHLIB) $(BLD_MOD_DIR)
63# chmod 755 $(BLD_MOD_DIR)/libcrypto*$(BLD_SHLIB)
64# @if [ "$(BLD_HOST_OS)" = "LINUX" -a -f /etc/redhat-release -a -x /usr/bin/chcon ] ; then \
65# if [ "`sestatus | grep enabled`" != "" ] ; then \
66# echo chcon /usr/bin/chcon -t texrel_shlib_t $(BLD_MOD_DIR)/libcrypto.so; \
67# priv chcon /usr/bin/chcon -t texrel_shlib_t $(BLD_MOD_DIR)/libcrypto.so; \
68# fi ; \
69# fi
70# [ -x /sbin/ldconfig ] && ldconfig -n $(BLD_MOD_DIR) ; true
71
72#$(BLD_MOD_DIR)/libssl$(BLD_SHLIB): $(BLD_OPENSSL_DIR)/libssl$(BLD_SHLIB)
73# cp $(BLD_OPENSSL_DIR)/libssl*$(BLD_SHLIB) $(BLD_MOD_DIR)
74# chmod 755 $(BLD_MOD_DIR)/libssl*$(BLD_SHLIB)
75# @if [ "$(BLD_HOST_OS)" = "LINUX" -a -f /etc/redhat-release -a -x /usr/bin/chcon ] ; \
76# then \
77# if [ "`sestatus | grep enabled`" != "" ] ; then \
78# echo chcon /usr/bin/chcon -t texrel_shlib_t $(BLD_MOD_DIR)/libssl.so; \
79# priv chcon /usr/bin/chcon -t texrel_shlib_t $(BLD_MOD_DIR)/libssl.so; \
80# fi ; \
81# fi
82# [ -x /sbin/ldconfig ] && ldconfig -n $(BLD_MOD_DIR) ; true
endif
2.添加openssl时所需选项如下:
[root@localhost appweb-src-2.4.2]# CC_FOR_BUILD=gcc CC=arm-linux-gcc AR=arm-linux-ar LD=arm-linux-ld STRIP=arm-linux-strip ./configure --host=arm-s3c2410-linux --disable-shared --port=80 --with-ssl=builtin --with-openssl=builtin --with-openssl-dir=/opt/sheji/openssl/lib --with-openssl-libpath=/opt/sheji/openssl/lib --with-openssl-iflags="-I /opt/sheji/openssl/include" --with-openssl-libs="ssl crypto"
3.复制/opt/sheji/appweb-src-2.4.2/appweb下的相应文件到/opt/nfsroot/mnt/etc/appweb,如下:
[root@localhost appweb-src-2.4.2]# ls /opt/nfsroot/mnt/etc/appweb/
appweb.conf mime.types response.client server.key users.dist
openssl.ca response.server server.key.pem
groups.dist openssl.conf server.crt
我也不知道都需要哪些,就都放到这里了,有空可以试一下。
注意:原来配置成用Matrixssl时的那几个同名文件不能用,在没有复制上面几个openssl相关的文件时,打上地址提示找不到网页,换上相应文件就可以访问了。
另外默认情况下编译成DEBUG模式如果要用在产品中还要添加如下选项:--type=RELEASE
意外收获:在linux box下我们可以用ldd查看哪个可执行文件链接了哪些库,但是在arm下没有相应的arm-linux-ldd命令,但你可以用下面的命令完成类似的功能:
[root@localhost appweb-src-2.4.2]# arm-linux-objdump -x /opt/nfsroot/usr/sbin/appweb |grep NEEDED
NEEDED libpthread.so.0
NEEDED libdl.so.2
NEEDED libc.so.6
虽然配置时是静态的但是还是要调用动态库,我也不知道为什么?????
还有一些没有做的事:
静态编译的可执行文件太大,strip后还有1.8M,这对于开发板来说太大了,看看有空动态编译一下digi passport上边就是动态编译的。
尚未解决或要做的是:
1.错误:
~ # appweb -f appweb.conf &
~ # default:1 main Error: Can't log errors to /var/log/appweb/error.log:2
default:1 main Error: Ignoring bad directive "ErrorLog" at line 22 in /etc/appweb/appweb.conf
default:1 main Error: Bad group name: nobody default:1 main Error: Can't open log file /var/log/appweb/access.log
2.支持PHP
参考: