您的位置:首页 > 其它

嵌入式web server boa 在S3C6410上的移植

2010-07-26 19:50 253 查看
 

嵌入式web server boa 在S3C6410上的移植
开发平台:LINUX
目标平台:S3c6410
开发工具:arm 交叉工具链版本4.3.2 
boa版本:boa-0.94.13.tar.gz
 
一、下载源码,生成makefile
     1.下载源码
     2.解压 tar zxvf boa-0.94.13.tar.tar
     3.cd boa-0.94.13/src
     4. ./configure          (生成Makefile)
 
二、编译前,修改文件
1.    修改Makefile文件,找到CC=gcc和CPP=gcc -E,分别将其改为交叉编译器安装的路径:
CC=  arm-linux-gcc
CPP= arm-linux-gcc -E
修改编译方式:
          LDFLAGS = -g –static
注: 使用静态编译可以让目标文件自动的包含所需要的库文件,而动态编译需要手工拷贝库文件。
保存退出。(必须保证宿主机上配置好了交叉编译器)
2.   make 
编译时用2.95.3以上的版本会出错:
util.c: 100: 1: pasting “t” and “->” does not give a valid preprocessing token make: [util.o] Error1
解决方法:
方法1>. 修改compat.h中的把第120 行的
#define TIMEZONE_OFFSET(foo) foo## ->tm_gmtoff
改为:#define TIMEZONE_OFFSET(foo) foo->tm_gmtoff
方法2>. 改用2.95.3版本的编译器
错误:
                     make: yacc:命令未找到
                     make: *** [y.tab.c] 错误 127
                    
f400
make: lex:命令未找到
                     make: *** [lex.yy.c] 错误 127
     解决:  sudo apt-get install bison flex 
 
 三. 修改配置文件boa.conf
.     在boa.conf中的修改:
(1) ServerName的设置
 修改#ServerName www.your.org.here
为 ServerName www.your.org.here
      注意:该项默认为未打开,执行Boa会异常退出,提示“gethostbyname::No such file or directory”,所以必须打开。其它默认设置即可。 
    注意:以下是为改为下面这样的:
(2)User与Group的修改:
    User 0
    Group 0
(3)ErrorLog /var/log/boa/error_log
    AccessLog /var/log/boa/access_log
 (4)DocumentRoot /var/www
 (5)DirectoryIndex index.html
 (6)KeepAliveMax 1000
    KeepAliveTimeout 10
 (7)MimeTypes /etc/mime.types
 (8)ScriptAlias /cgi-bin/ /var/www/cgi-bin/
四   在var目录下创建
mkdir –m 777 log
         mkdir –m 777 log/boa
         mkdir –m 777 www
         mkdir –m 777 www/cgi-bin
拷贝PC上/etc/mime.types文件到开发板/etc目录下
    (或者将boa.conf文件中  MimeTypes /etc/mime.types     修改为:   MimeTypes /dev/null  )
    
建立/etc/boa目录, 并复制boa.conf到/etc/boa目录下。
 
五 启动boa
#boa
#ps                      查看是否有boa进程
                     若无查看/var/log/boa/error_log
 
1>. 错误1: gethostbyname:: No such file or directory
     解决办法: 修改boa.conf   去掉 ServerName www.your.org.here 前的注释符号(#)
 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     
                                                         
三、重新编译并移植
  1.编译 boa
      # make
      # arm-linux-strip boa
 
  2,将mime.types文件复制目标板根文件系统/etc目录下
  3。在开发板上
        cd /etc
        mkdir boa
    把开发机上的 (配置文件)boa.conf  (编译结果)boa  defines.h 这3个文件拷贝到开发板/etc/boa/ 下
 
 4.  在开发板上
      cd /var
      mkdir  www  (这个文件夹内可以放网页)
      mkdir /var/log/boa
 
四、 编写CGI脚本测试
1、编写Helloworld.c程序
int main(void)
{
      printf("Content-type:text/html/n/n"); //这句一定要加上
      printf(" Hello,world.");
      exit(0);
}
 
arm-linux-gcc -o helloworld.cgi helloworld.c
 
2、浏览
    将helloworld.cgi拷贝至/var/www/cgi-bin/下,浏览器输入开发板IP地址即可看到web信息,注意要同一网段
 
 

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