移植BOA

移植BOA

1、实验环境

平台 FS4412
源码包 boa-0.94.13.tar.tar
交叉编译工具链 arm-linux-

2、BOA服务器移植

  1. 解压源码

    tar xvf boa-0.94.13.tar.tar
    cd boa-0.94.13
  2. 修改Makefile

    $ ./configure   生成Makefile
    $ vi Makefile 

    修改内容如下:

    1、修改
    CC = gcc 为 CC = arm-linux-gcc
    2、修改
    CPP = gcc -E 为 CPP = arm-linux-gcc -E
  3. 编译

    编译一个linux下的c系统,需要包含词法和语法分析模块,Linux上常用的是用bison和flex,所以需要安装这两个模块

    $ apt-get install bison flex
    $ make 
    $ arm-linux-strip boa #减小boa的体积

3、Boa服务器配置

  1. 创建目录

    mkdir /source/rootfs/etc/boa
  2. 将boa源码目录下的boa.conf拷贝到/source/rootfs/etc/boa目录下

    cp boa.conf /source/rootfs/etc/boa
  3. 修改配置文件boa.conf

    vim  /source/rootfs/etc/boa

    修改内容如下:

    (1) Group的修改

    修改 Group nogroup

    Group 0

    (2)User nobody的修改

    修改User nobody

    User 0

    (3)ScriptAlias的修改

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

    ScriptAlias /cgi-bin/ /www/cgi-bin/

    (5)DocumentRoot的修改

    修改DocumentRoot /var/www

    DocumentRoot /www

    (6)ServerName的设置

    修改#ServerName www.your.org.here

    ServerName www.your.org.here

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

    (7)AccessLog修改

    修改AccessLog /var/log/boa/access_log

    #AccessLog /var/log/boa/access_log

  4. 以下配置和boa.conf的配置有关,都是在ARM根文件系统中创建

    1. 创建HTML文档的主目录/www

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

      mkdir /www/cgi-bin

    当不能使用cgi 时

    将#AddType application/x-httpd-cgi cgi改为AddType application/x-httpd-cgi cgi

4、Boa测试

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

    cp src/boa/source/rootfs/etc/boa
  2. 将ubuntu下/etc/mime.types拷贝到开发板根文件系统的/etc下

    cp /etc/mime.types/source/rootfs/et
  3. 将你的主页index.html拷贝到www目录下

  4. 运行boa,然后在主机游览器输入开发板网址

    
    # ./boa
    

    如果出现以下信息则启动成功

    [30/10/2011:19:10:36 +0000] boa: server version Boa/0.94.13
    [30/10/2011:19:10:36 +0000] boa: server built 10 30 2011 at 19:10:36
    [30/10/2011:19:10:36 +0000] boa: starting server pid=968, port 80

5、问题及解决方法

  1. 错误1

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

    解决方法:

    //修改 src/compat.h 
    define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff 
    //修改成 
    define TIMEZONE_OFFSET(foo) (foo)->tm_gmtoff 
  2. 错误2:

    [01/Jan/1970:00:56:51 +0000] log.c:73 - unable to dup2 the error log: Bad file descriptor

    解决方法:

    1、修改 src/log.c
    2、注释掉
    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. 错误3:

    [01/Jan/1970:01:01:15 +0000] boa.c:226 - icky Linux kernel bug!:No such file or directory

    解决方法:

    1、修改src/boa.c
    2、修改:
    if (setuid(0) != -1) {
    DIE("icky Linux kernel bug!");
    }
    为:
    if (setuid(0) != -1) {
    WARN("icky Linux kernel bug!");
    }
  4. 错误4:

    [01/Jan/1970:01:01:15 +0000] boa.c:211 - getpwuid: No such file or directory

    解决方法:

    1、修改src/boa.c
    2、注释掉下面两句话:
    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
    

你可能感兴趣的:(移植BOA)