BOA 移植

1 下载 boa-0.94.13.tar 官方网址:www.boa.org

2 解压缩
   tar zxvf boa-0.94.13.tar.gz

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

出现上面的错误,原来该包没有经过gzip格式压缩,所以解压时

tar xvf boa-0.94.13.tar.gz
即可

3 进入/boa-0.94.13/src目录,运行./configure 生成Makefile

4 修改Makefile
  CC = arm-none-linux-gnueabi-gcc
  CPP = arm-none-linux-gnueabi-gcc -E


5 编译出现错误

    steven@ubuntu:~/work/newgui/boa/boa-0.94.13/src$ make
    byacc  -d boa_grammar.y
    arm-none-linux-gnueabi-gcc -g -O2 -pipe -Wall -I.   -c -o y.tab.o y.tab.c
    y.tab.c: In function 'yyparse':
    y.tab.c:367: warning: implicit declaration of function 'yylex'
    lex  boa_lexer.l
    make: lex: Command not found
    make: *** [lex.yy.c] Error 127


  因为没有安装bison 和 flex
  sudo apt-get install bison flex

6 继续编译又出现错误
 
  util.c: In function 'get_commonlog_time':
  util.c:100: error: pasting "t" and "->" does not give a valid preprocessing token
-----------------------------------------------------------------------------------
解决办法:
  打开util.c在函数char *get_commonlog_time(void)
  将time_offset = TIMEZONE_OFFSET(t);
  修改为:time_offset = 0;

7 继续编译
  成功后在src目录下生成可执行文件boa以及boa_indexer

  steven@ubuntu:~/work/newgui/boa/boa-0.94.13/src$ file boa
  boa: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
-------------------------------------------------------------------------------------

8 在目标板上建立相关目录
 
  建立/etc/boa目录
  因为我们的目标板的etc都是在mnt下拷贝过去的,所以我们/mnt/etc/下建立相关目录
 
  拷贝boa、boa_indexer、defines.h、boa.conf 到mnt/etc/boa下
 
  修改boa.conf文件
 
  修改 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  改为 ScriptAlias /cgi-bin/ /var/www/cgi-bin/

  修改 DirectoryMaker /usr/lib/boa/boa_indexer
  改为 DirectoryMaker /etc/boa/boa_indexer

9 在目标板建立需要的文件夹
   mkdir /var/boa/www  /var/www/cgi-bin   /var/log/boa
----------------------------------------------------
10 在目标板上运行boa服务器
        [root@ubuntu:/etc/boa]$./boa
    No such user: nobody
   此时,需要修改boa.conf
   将      User nobody
             Group nogroup
   改为:User 0
              Group 0
-------------------------------------------------------   
11 接着再一次在目标板上运行boa服务器
   [root@ubuntu:/etc/boa]$./boa
    Could not open mime.types file, "/etc/mime.types", for reading

   提示没有这个mime.types文件
   我们将ubuntu系统里的这个文件拷贝到目标板/mnt/etc/目录下
   cp /etc/mime.types /home/steven/NFS/rootfs/mnt/etc/

-----------------------------------------------------
12 接着再一次在目标板上运行boa服务器
   [root@ubuntu:/etc/boa]$./boa
   gethostbyname:: Resource temporarily unavailable  
   
   提示无法获取主机名
   
   修改boa.conf
   去掉注释
   ServerName www.your.org.here
-----------------------------------------------------
13 再一次在目标板上运行boa服务器
   成功
   [root@ubuntu:/etc/boa]$./boa
   [root@ubuntu:/etc/boa]$

   系统没有任何反应,ps查看进程 也没有boa
   借助log文件查看错误
   
   打开/var/log/boa/ error_log 发现

   [22/Jan/2000:03:29:33 +0000] boa.c:226 - icky Linux kernel bug!: No such file or
   [22/Jan/2000:03:50:29 +0000] boa.c:226 - icky Linux kernel bug!: No such file or
   [22/Jan/2000:03:58:03 +0000] boa.c:226 - icky Linux kernel bug!: No such file or
   [22/Jan/2000:04:01:11 +0000] boa.c:226 - icky Linux kernel bug!: No such file or


   解决办法是回到src源码目录下打来boa.c文件,注释掉与icky相关语句
   /*
        if (setuid(0) != -1) {
            DIE("icky Linux kernel bug!");
        }
  */
  /*      
      if (passwdbuf == NULL) {
            DIE("getpwuid");
        }
  */
再一次重新编译源代码

并拷贝到目标板后运行,ps后发现boa进程
 580 root      2188 S    ./boa
 581 root      2148 R    ps
 此时说明boa服务器进程已经运行

-----------------------------------------------------
14 测试
     修改boa.conf在最后一行添加
     ScriptAlias /index.html /var/www/index.html
     
     打开浏览器,任意保存一个网页为html 格式,如index.html
     拷贝index.html 文件到/var/www 目录下。
     在浏览器地址栏输入 http://localhost 就可以看到了!

测试中使用的是boa 官方主页:
测试结果OK。
在地址栏输入 http://192.168.1.11/

出现boa webserver

-----------------------------------------------------
15 cgi 脚本测试

   写一个简单的hello.c源代码
 #include<stdio.h>
int main()
{
    printf("Content-type: text/html\n\n");
    printf("<html>\n");
    printf("<head><title>BOA CGI TEST</title></head>\n");
    printf("<body>\n");
    printf("<h1>BOA CGI TEST</h1>\n");
    printf("</body>\n");
    printf("</html>\n");
    exit(0);
}


编译arm-none-linux-gnueabi-gcc -o cgi_test.cgi cgi_test.c

将得到的cgi_test.cgi拷贝到目标板var/www/cgi-bin/目录下
cp cgi_test.cgi /home/steven/NFS/rootfs/var/www/cgi-bin/

在浏览器中输入http://192.168.1.11/cgi-bin/cgi_test.cgi

会看到预期结果
BOA CGI TEST


----------------------------------------------------------------
16 让boa服务器开机自动运行
   
   在开发板的etc/inittab文件中添加如下
   ::wait:/etc/boa/boa&

   比如:
#/etc/inittab
::sysinit:/etc/init.d/rcS
#console::askfirst:-/bin/sh
::respawn:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::wait:/etc/boa/boa&

重启系统后 ps查看进程
  579 root      2188 S    /etc/boa/boa
  580 root         0 SW   [flush-0:12]
  581 root      2148 R    ps
发现boa已经运行

在浏览器中输入http://192.168.1.11测试成功









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值