天嵌 ARM开发社区

 找回密码
 注册
查看: 2497|回复: 0

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

[复制链接]
embedhq 发表于 2010-8-11 13:46:30 | 显示全部楼层 |阅读模式
本帖最后由 embedhq 于 2010-8-11 13:48 编辑

作者:华清远见武汉华嵌嵌入式培训中心 讲师 李家凯    www.embedhq.org
嵌入式web server boa 在TQ2440上的移植

开发平台:ubuntu 8.04
目标平台:TQ2440
开发工具:arm 交叉工具链版本3.4.5   
boa版本:boa-0.94.13.tar.gz

一、下载源码,生成makefile
     1. 下载源码:http://www.boa.org/
     2. 拷贝到 /opt 目录下
     3.解压 tar zxvf boa-0.94.13.tar.tar
     4.cd boa-0.94.13/src
     5. ./configure

二、编译前,修改文件
1.  修改Makefile文件,找到CC=gcc和CPP=gcc -E,分别将其改为交叉编译器安装的路径:
CC=  arm-softfloat-linux-gnu-gcc
CPP= arm-softfloat-linux-gnu-g++
保存退出。

2. 修改编译方式:
LDFLAGS = -g –static
注: 使用静态编译可以让目标文件自动的包含所需要的
库文件,而动态编译需要手工拷贝库文件。
3.修改/src/defines.h文件:

#define SERVER_ROOT "/etc/boa"

4 修改boa-0.94/src/ util.c文件
修改char *get_commonlog_time(void)函数。
time_offset = 0;

5. 修改src/config.c:加Current_uid=1

6. 修改compat.h: 把第120 行的
#define
TIMEZONE_OFFSET(foo)foo##->tm_gmtoff
修改为:
#define
TIMEZONE_OFFSET(foo)foo->tm_gmtoff

7.修改/src/boa.c,注释掉下面两行:
/* if (setuid(0) != -1) {
            DIE("icky Linux kernel bug!");
        } */

/*if (passwdbuf == NULL) {
            DIE("getpwuid");
        }*/

8 :config.c
/*if (!server_name) {
        struct hostent *he;
        char temp_name[100];

        if (gethostname(temp_name, 100) == -1) {
            perror("gethostname:");
            exit(1);
        }

        he = gethostbyname(temp_name);
        if (he == NULL) {
            perror("gethostbyname:");
            exit(1);
        }

        server_name = strdup(he->h_name);
        if (server_name == NULL) {
            perror("strdup:");
            exit(1);
        }
    }*/

9. /src/log.c中的修改:注释掉:
/*     if (dup2(error_log, STDERR_FILENO) == -1) {
            DIE("unable to dup2 the error log");
        } */
                                                           
10. 在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/
   
三、编译并移植
  1.编译 boa
      # make
      # arm-softfloat-linux-gnu-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-softfloat-linux-gnu-gcc -o helloworld helloworld.c

2、浏览
    将helloworld拷贝至/var/www/cgi-bin/下,浏览器输入开发板IP地址即可看到web信息。

(转载请注明出处: 武汉华嵌  www.embedhq.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号-2 )

GMT+8, 2024-9-27 21:05 , Processed in 1.020547 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表