arm/6410移植boa服务器

一、boa下载和安装:
、修改编译安装文件:

)在www.boa.org下载boa-0.94.13.tar.gz 并解压

)在src目录下运行./configure生成Makefile。

)生成Makefile文件,修改

                 CC = arm-linux-gcc

–E

、修改boa.c源文件

boa.c文件中以下几行判断注释掉。

            

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

         改为

          

/*if (setuid(0) != -1) {
                     DIE("icky Linux kernel bug!");
              }*/

、修改文件compat.h

     

#define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff
         修改成
         #define TIMEZONE_OFFSET(foo) (foo)->tm_gmtoff

、执行#make 命令

        

#make
         #arm-linux-strip boa

二、配置boa.conf

在/etc目录下建立一个boa目录,里面放入Boa的主要配置文件boa.conf。在Boa源码目录下已有一个示例boa.conf,可以在其基础上进行修改

     1、Group的修改

             修改 Group nogroup

             为 Group 0

             修改 User nobody

             为 User 0

     2、ScriptAlias的修改

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

           为 ScriptAlias /cgi-bin/ /var/www/cgi-bin/

      3、ServerName的设置

          修改 ServerName www.your.org.here

          为 ServerName  yourname

      注意:该项默认为未打开,执行Boa会异常退出,所以必须打开,把前边#号去掉,其它默认设置即可。

     在boa.conf的控制文件中可以设置 ErrorLog 为 /etc/console这样错误信息,就可以马上输出到控制台上了,其实我移植的时候,这些都是默认的。若在移植的过程中出现:

 

boa.c:266.icky Linux kernel bug!:No such file。

解决该问题的方法是将boa.c文件中以下几行判断去掉即可。

   

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

常见错误:

      1>.错误:make: yacc: Command not found

                解决办法:apt-get install -y byacc

                错误:make: lex: Command not found

                解决办法:apt-get install -y flex

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

: 修改boa.conf 去掉 ServerName www.your.org.here(#)

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

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

     5>. 错误3: boa.c:228 - icky Linux kernel 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

     

第三部:Boa的执行

成功配置以后,还需要创建日志文件所在目录/var/log/boa,创建HTML文档的主目录/var/www,将静态网页存入该目录下(可以将主机 /usr/share/doc/HTML/目录下的index.html文件和img目录复制到/var/www目录下),创建CGI脚本所在录/var /www/cgi-bin,将cgi的脚本存放在该目录下。另外还要将mime.types文件复制/etc目录下,通常可以从linux主机的/etc 目录下直接复制即可.

./boa &

第四步 CGI脚本测试

1、编写Helloworld.c程序

1 #include <stdlib.h>
  2 #include <stdio.h>
  3
  4 void main() {
  5     printf("Content-type: text/html\n\n") ;
  6     printf("\n") ;
  7     printf("CGI Output\n") ;
  8     printf("\n") ;
  9     printf("Hello, world.\n") ;
 10     printf("\n") ;
 11     printf("\n") ;
 12     exit(0) ;
 13 }

        交叉编译生成helloworld.cgi

       # /usr/local/arm/2.95.3/bin/arm-linux-gcc -o helloworld.cgi helloworld.c

    2、浏览

            将helloworld.cgi拷贝至/var/www/cgi-bin/下,浏览器输入

            ip/cgi-bin/helloworld.cgi

            这样就OK了。

6410linux3.0.1下 开机自启动:

        vi /etc/init.d/rcS

        末尾添加:

      

#/sbin/boa
                /etc/boa/boa
               cd /var/
               mkdir -m 777 www
               mkdir -m 777 www/cgi-bin
               cp /sdcard/helloworld.cgi www/cgi-bin/

       浏览器中192.168.1.119/cgi-bin/helloworld.cgi