您的位置:首页 > 其它

boa web服务器移植

2014-04-02 10:33 387 查看
Boa是一种非常小巧的Web服务器,其可执行代码只有大约60KB左右。作为一种单任务Web服务器,Boa只能依次
完成用户的请求,而不会fork出新的进程来处理并发连接请求。但Boa支持CGI,能够为CGI程序fork出一个进程来执行,Boa的设计目标是速度和安全。

MPlayer版本:

madplay-0.15.2b.tar.gz

交叉编译器版本:

arm-linux-gcc 4.1.2

操作系统平台:

Linux -- ubuntu11.04

所需源码:

boa-0.94.13.tar.gz

一 :安装交叉编译工具(略)

二 :编译 boa-0.94.13.tar.gz

#tar xzvf boa-0.94.13.tar.gz

#cd
boa-0.94.13/

#cd
src/

##./configure

#vim
Makefile

修改Makefile

CC = gcc
CPP = gcc -E
该为:
CC = arm-linux-gcc
CPP = arm-linux-gcc -E

#make

出现错误:

yacc -d boa_grammar.y

make: yacc:命令未找到

解决方法:

# sudo
apt-get install bison flex

#make

出现错误:

util.c:100:1: error: pasting "t" and "->" does not give a valid preprocessing token

make:
*** [util.o] 错误 1
解决方法:
修改
src/compat.h
#define
TIMEZONE_OFFSET(foo) foo##->tm_gmtoff
修改成
#define TIMEZONE_OFFSET(foo) (foo)->tm_gmtoff

#make

出现错误:
log.c:73
unable to dup2 the error log:bad file deor
解决方法:
修改
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");

}*/

#make

出现错误:

boa.c:211 - getpwuid: No such file or directory

解决方法:

修改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

#make

出现错误:

boa.c:228 - icky Linux kernel bug!: No such file
or directory

解决方法:

修改src/boa.c

if (setuid(0) != -1) {

DIE(”icky Linux kernel bug!”);

}



#if 0

if (setuid(0) != -1) {

DIE(”icky Linux kernel bug!”);

}

#endif

#make

#arm-linux-strip
boa //去掉调试信息,减少boa体积

Boa的配置

这一步的工作也在电脑主机上完成。

在boa-0.94.13目录下已有一个示例boa.conf,可以在其基础上进行修改。如下:

#vim boa.conf

(1)Group的修改

修改 Group nogroup

为 Group 0

(2)user的修改

修改 User nobody

为 User 0

(3)Alias的修改

修改Alias /cgi-bin/ /usr/lib/cgi-bin/

为 Alias /cgi-bin/ /www/cgi-bin/

(5)DoucmentRoot的修改

修改DoucmentRoot /var/www

为DoucmentRoot /www

(6)ServerName的设置

修改#ServerName www.SHAEEONE.net

为 ServerName www.SHAEEONE.net

否则会出现错误“gethostbyname::No such file or directory”

(7)AccessLog修改

修改AccessLog /var/log/boa/access_log

为#AccessLog /var/log/boa/access_log

否则会出现错误提示:“unable to dup2 the error log: Bad file deor”

(8)以下配置和boa.conf的配置有关,都是在arm根文件系统中创建

以下步骤在开发板上进行:

创建目录/etc/boa并且把boa 和 boa.conf拷贝到这个目录下

mkdir /etc/boa

创建HTML文档的主目录/www

mkdir /www

创建CGI脚本所在录 /www/cgi-bin

mkdir /www/cgi-bin

以下步骤在ubuntu下进行:

将boa.conf拷贝到开发板根文件系统的/etc/boa下

#cp boa.conf /source/rootfs/etc/boa

将boa拷贝到开发板根文件系统的/etc/boa下

#cp src/boa /source/rootfs/etc/boa

将ubuntu下/etc/mime.types拷贝到开发板根文件系统的/etc下

#cp /etc/mime.types /source/rootfs/etc

将你的主页index.html拷贝到www目录下

(9)测试

打开一个浏览器输入开发板ip看看效果

It's OK!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: