嵌入式web server boa在S3C2410上的编译移植步骤

嵌入式web server boa在S3C2410上的编译移植步骤,第1张

开发平台:ubuntu 8.04

目标平台:S3c2410

开发工具:arm 交叉工具链版本3.4.5  

boa版本:boa-0.94.13.tar.gz

一、下载源码,生成makefile

1. 下载源码:

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

为 ServerName

注意:该项默认为未打开,执行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/htmlnn"); //这句一定要加上

printf(" Hello,world.");

exit(0);

}

arm-softfloat-linux-gnu-gcc -o helloworld helloworld.c

2、浏览

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/dianzi/2716223.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-08-17
下一篇 2022-08-17

发表评论

登录后才能评论

评论列表(0条)

保存