Chinaunix首页 | 论坛 | 博客
  • 博客访问: 757154
  • 博文数量: 231
  • 博客积分: 3217
  • 博客等级: 中校
  • 技术积分: 2053
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-04 12:01
文章分类

全部博文(231)

文章存档

2015年(1)

2013年(10)

2012年(92)

2011年(128)

分类:

2011-08-19 16:59:08

原文地址:web服务器Boa移植 作者:luozhiyong131

 说明:Boa服务器的移植是在arm平台上移植,即在开发板上的linux下,

> 编译boa程序

1. 下载boa-0.94.13.tar.gz

2. 解压进入src/

3. #./configure

修改Makefile文件: :

CC = gcc

CPP = gcc -E

该为:

CC = arm-linux-gcc

CPP = arm-linux-gcc -E

 

拷贝PC/etc/mime.types文件到开发板/etc目录下

如果不用mimi.types,可将boa.conf文件中

MimeTypes /etc/mime.types

修改为:

MimeTypes /dev/null

修改配置文件boa.conf

1. 建立/etc/boa目录, 并复制boa.conf/etc/boa目录下,并按照以下步骤进行修改。

2. 修改访问权限:修改User nobody User 0 ; 修改Group nogroup Group 0

3. 设定日志目录:boa日志有两部分,Errorlog AccessLog

一般情况下为/var/log/boa/error_log /var/log/boa/access_log两个文件。所以根据自己的情况情况设置日志目录:

ErrorLog /var/log/boa/error_log

AccessLog /var/log/boa/access_log

(注意:这里/var/log/boa目录必须为可写,否则会出项错误:log.c:73 Unable to dup2 the error log: Bad file r.)

在启动脚本里将var挂载成ramfs: mount n t ramfs ramfs /var

# mkdir p /var/log/boa

# chmod 666 /var/log/boa

 

4. 设置html文件目录: DocumentRoot /var/www

# mkdir /var/www

在此目录下存放html文件(包括index.html文件)

 

5. 设置默认首页: DirectoryIndex index.html

6. 设置cgi脚本目录:

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin

修改为

ScriptAlias /cgi-bin/ /var/cgi-bin

目录可以自己修改,但是要和网页存放的目录一致(保存cgi脚本文件)

# mkdir /var/cgi-bin

 

编译

# make

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

复制生成的boa文件放到usr/bin目录。

编译会出错: util.c: 100: 1: pasting t and -> does not give a valid preprocessing token make: [util.o] Error1

 解决方法: 修改compat.h中的

#define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff

改为:

#define TIMEZONE_OFFSET(foo) foo->tm_gmtoff

 

在开发板上运行boa,在主机IE上输入开发板IP,可看到网页

 

常见错误:

这些错误内容可查看/var/log/boa/error_log文件

1>. 错误1: gethostbyname:: No such file or directory

解决办法: 修改boa.conf 去掉 ServerName 前的注释符号(#)

2>. 错误1: util.c:100:1: error: pasting "t" and "->" does not give a valid preprocessing token make: *** [util.o]

解决办法: 修改 src/compat.h

找到

#define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff

修改成

#define TIMEZONE_OFFSET(foo) (foo)->tm_gmtoff

3>. 错误2: 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

                                      

4>. 错误3: 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

5>. 错误4: log.c:73 unable to dup2 the error log:bad file descriptor

解决方法:

方法1> 确定日志目录对与所有用户都具有可读/写的权限

方法2> 修改src/log.c (建议采用方法1)

注释掉

if (dup2(error_log, STDERR_FILENO) == -1) {

DIE("unable to dup2 the error log");

}

即修改为:

#if 0

if (dup2(error_log, STDERR_FILENO) == -1) {

DIE("unable to dup2 the error log");

}

#endif

 

阅读(351) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~