boa移植到android平台上

http://blog.csdn.net/s762888517/article/details/6948244

一 、到http://www.boa.org/上下载bor服务器,本人用的是0.94.13版本。
二、将其解压到android源码根目录下的external/boa中
三、在boa文件夹下创建Android.mk文件,具体内容如下

ifeq ($(TARGET_ARCH),arm)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false
LOCAL_SRC_FILES:= src/lex.yy.c \
src/y.tab.c \       //TAB间隔,自己把握
src/alias.c \
src/boa.c \
src/buffer.c \
src/cgi.c \
src/cgi_header.c \
src/config.c \
src/escape.c \
src/get.c \
src/hash.c \
src/ip.c \
src/log.c \
src/mmap_cache.c \
src/pipe.c \
src/queue.c \
src/read.c \
src/request.c \
src/response.c \
src/select.c \
src/signals.c \
src/util.c \
src/sublog.c \
src/timestamp.c
LOCAL_SHARED_LIBRARIES := \
libcutils
LOCAL_C_INCLUDES += $(LOCAL_PATH)/src 
LOCAL_MODULE:= libmy
include $(BUILD_SHARED_LIBRARY) //生成libmy库
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= src/lex.yy.c \
src/y.tab.c \  //TAB间隔,自己把握     
src/alias.c \
src/boa.c \
src/buffer.c \
src/cgi.c \
src/cgi_header.c \
src/config.c \
src/escape.c \
src/get.c \
src/hash.c \
src/ip.c \
src/log.c \
src/mmap_cache.c \
src/pipe.c \
src/queue.c \
src/read.c \
src/request.c \
src/response.c \
src/select.c \
src/signals.c \
src/util.c \
src/sublog.c \
src/timestamp.c
LOCAL_CFLAGS := -g -O2 -pipe -Wall -I.
 
LOCAL_SHARED_LIBRARIES := \
libcutils libmy
LOCAL_C_INCLUDES += $(LOCAL_PATH)/src 
LOCAL_MODULE:= boa
include $(BUILD_EXECUTABLE)
endif  

四、修改boa源码

(1)修改 src/compat.h
#define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff
修改成
#define TIMEZONE_OFFSET(foo) (foo)->tm_gmtoff

(2)修改 src/log.c
if (dup2(error_log, STDERR_FILENO) == -1) {
DIE("unable to dup2 the error log");
  }
为:
/*if (dup2(error_log, STDERR_FILENO) == -1) {
DIE("unable to dup2 the error log");
  }*/

(3)修改src/boa.c
if (passwdbuf == NULL) {
DIE(”getpwuid”);
}
if (initgroups(passwdbuf->pw_name, passwdbuf->pw_gid) == -1) {
DIE(”initgroups”);
}

#if 0
if (passwdbuf == NULL) {
DIE(”getpwuid”);
}
if (initgroups(passwdbuf->pw_name, passwdbuf->pw_gid) == -1) {
DIE(”initgroups”);
}
#endif

(4)修改src/boa.c
 if (setuid(0) != -1) {
DIE(”icky Linux kernel bug!”);
}

#if 0
if (setuid(0) != -1) {
DIE(”icky Linux kernel bug!”);
}
#endif

五、编译
回到android源码根目录下,执行. build/envsetup.sh,之后执行mmm external/boa编译boa源码

六、配置boa.conf
 1)修改 Group nogroup为 Group 0  修改 User nobody为 User 0
 2)修改 ErrorLog /var/log/boa/error_log为 #ErrorLog /var/boa/log/error_log
 3) 修改 AccessLog /var/log/boa/access_log为 #AccessLog /var/boa/log/access_log
 4)修改 #ServerName www.your.org.here为 ServerName www.your.org.here
 5)修改 DocumentRoot /var/www为 DocumentRoot /etc/boa/www
 6)修改 MimeTypes /etc/mime.types为 MimeTypes /etc/boa/mime.types
 7)修改 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/为ScriptAlias /cgi-bin/ /etc/boa/www/cgi-bin/
 
七、由于开发板中的etc目录位于android源码下的out/target/product/rk29sdk/system/etc下,所以在该目录下创建如下目录:
  /etc/boa/
 /etc/boa/log
 /etc/boa/www
 /etc/boa/www/cgi-bin/
(1)将boa.conf拷贝到/etc/boa目录下
(2)把mime.types拷到/etc/boa目录下,mime.types可以从自己机子的/etc目录下取得。
(3)把静态html页面拷到/etc/boa/www目录下。

八、执行./mkimage生成system.img,将其烧到板子上。

九、测试
 (1)启动目标板的wifi热点。
 (2)将电脑连接到目标板的wifi热点上。
 (3)执行adb shell进入命令界面,执行boa,启动目标板的boa服务器。
 (4)在浏览器上输入wifi热点的ip地址(可在命令界面执行busybox ifconfig命令进行查看),如果正常,你将能看到刚放进去的html页面。


<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(63) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
posted @ 2016-02-01 00:00  张同光  阅读(94)  评论(0编辑  收藏  举报