在嵌入式Linux系统(OK6410)中移植Boa 服务器
来源:互联网 发布:杯子知乎 编辑:程序博客网 时间:2024/05/01 16:50
OK6410的Boa服务器移植:
<一> Boa的编译
1. 从 www.boa.org 下载 Boa 服务器的最新版:boa-0.94.13.tar.gz。
2. 解压:tar xzf boa-0.94.13.tar.gz
3. 进入解压后的文件夹 boa-0.94.13内部的 src文件夹,对源文件进行如下修改
1 由于arm-linux-gcc 编译器版本过高,对语法的支持有一些改变,所以需要修改compat.h中的2 #define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff3 为:4 5 #define TIMEZONE_OFFSET(foo) foo->tm_gmtoff6 不然在编译的时候会提示如下错误:7 util.c: 100: 1: pasting “t” and “->” does not give a valid preprocessing token make: [util.o] Error1
1 将boa.c 文件225-227三行的文件注释掉 2 if (setuid(0) != -1) { 3 DIE(”icky Linux kernel bug!”); 4 } 5 为 6 /* 7 if (setuid(0) != -1) { 8 DIE(”icky Linux kernel bug!”); 9 }10 */11 12 ,否则,但以root权限启动boa服务器的时候,会出现以下错误:boa.c:226 - icky Linux kernel bug!:
4. 然后生成Makefile:./configure
5. 修改生成的Makefile:默认生成的Makefile针对x86平台,我们的目标是针对嵌入式平台,所以需要修改编译器.
1 更改Makefile的31行和32行:2 CC = gcc 3 CPP = gcc -E4 更改为5 CC = arm-linux-gcc6 CPP = arm-linux-gcc -E
6. 在当前目录下编译Boa源文件: make
7. 将生成好的boa可执行文件去掉冗余信息: arm-linux-strip boa. 如下图为strip 前后boa的大小对比。
<二> 将Boa移植到OK6410中
1. 修改boa.conf配置文件:
1 (1) 修改25行的port端口,用来设置服务器监听的端口: 2 # Port: The port Boa runs on. The default port for http servers is 80. 3 # If it is less than 1024, the server must be started as root. 4 5 Port 80 6 (2) 注释43行的监听IP地址:默认监听该主机上的所有IP地址 7 #Listen 192.68.0.5 8 (3) 修改53、54行的user和Group 启动的UID和GID,使其以root身份启动 9 # User: The name or UID the server should run as.10 # Group: The group name or GID the server should run as.11 12 User root13 Group root14 (4) 修改116行的DocumentRoot地址,即客户端要显示的HTML页面存放位置15 # DocumentRoot: The root directory of the HTML documents.16 # Comment out to disable server non user files.17 18 DocumentRoot /usr/local/boa19 (5) 修改输入网页输入主机IP时要显示的页面:这里设为index.html20 # DirectoryIndex: Name of the file to use as a pre-written HTML21 # directory index. Please MAKE AND USE THESE FILES. On the22 # fly creation of directory indexes can be _slow_.23 # Comment out to always use DirectoryMaker24 25 DirectoryIndex index.html26 (6) 修改CGI程序存放的位置:以http://IP/cgi-bin/cginame 的方式运行cgi 程序时将在/usr/local/boa/cgi-bin 目录下寻找该程序27 # ScriptAlias: Maps a virtual path to a directory for serving scripts28 # Example: ScriptAlias /htbin/ /www/htbin/29 30 ScriptAlias /cgi-bin/ /usr/local/boa/cgi-bin/
2. 将配置文件boa.conf 移动到OK6410的 /etc/boa/ 目录下。
3. 创建/var/log/boa/ 目录,这样Boa服务器启动时会在该目录下创建日志文件。
4. 将Linux系统上/etc/mime.types 文件复制到OK6410的/etc 目录下,否则Boa服务器启动不起来。
5. 将生成的boa文件移植到嵌入式板中的/sbin目录下并更改脚本文件 /etc/init.d/rcS, 新增一行: /sbin/boa ,确保boa服务器随系统上电自启动。
1
2
3
4
5
6
7
8
这里一定要注意:有时候boa服务器并不能随系统启动,运行 /sbin/boa 命令会提示:
gethostbyname:: Success
这种情况下要修改boa.conf 文件
将
#ServerName www.your.org.here
改为
ServerName www.your.org.here
即去掉注释即可
<三> 测试Boa服务器:
1. 静态页面测试:
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>Boa 静态网页测试</title> 6 </head> 7 8 <body> 9 <h1> Welcome to Boa sever! </h1>10 </body>11 </html>
2. CGI 程序测试:
1 #include <stdio.h> 2 int main() 3 { 4 printf("Content-type: text/html\n\n"); 5 printf("<html>\n"); 6 printf("<head>\n"); 7 printf("<title>CGI Output</title>\n"); 8 printf("</head>\n"); 9 10 printf("<body>");11 printf("<h1> Hello, world. </h1>");12 printf("</body>");13 printf("</html>\n");14 return 0;15 }
至此,Boa服务器移植完成。
0 0
- 在嵌入式Linux系统(OK6410)中移植Boa 服务器
- 在嵌入式Linux系统(OK6410)中移植Boa 服务器
- 在嵌入式Linux系统(OK6410)中移植Boa服务器
- 嵌入式boa服务器移植()
- OK6410的Boa服务器移植
- 基于嵌入式linux的Boa服务器移植
- 嵌入式Linux中的boa服务器的移植
- 嵌入式WEB服务器(BOA)移植
- 嵌入式web服务器移植(boa)
- 嵌入式linux web服务器boa的移植方法/arm开发板linux嵌入式web服务器boa
- 嵌入式boa服务器的移植
- {嵌入式}三种嵌入式web服务器(Boa / lighttpd / shttpd)的 linux移植笔记
- 嵌入式Linux下BOA网页服务器的移植
- 嵌入式Linux下BOA网页服务器的移植
- 嵌入式服务器SQLite3在ok6410开发板上的移植
- 三种嵌入式web服务器(Boa / lighttpd / shttpd)的 linux移植笔记
- 三种嵌入式web服务器(Boa / lighttpd / shttpd)的 linux移植笔记
- 三种嵌入式web服务器(Boa / lighttpd / shttpd)的 linux移植笔记 2
- Myeclipse的workspace配置文件浅谈 .
- Head First装饰模式(Decorator)
- chapter11 separate Compilition and Namespaces(part1)
- android模拟器按键对应的键盘按键
- 改错题_102
- 在嵌入式Linux系统(OK6410)中移植Boa 服务器
- Luasocket 服务器,客户端简单实例
- 好久没做asp了,这个天都在做asp,今天做asp操作xml,找了些资料才做出来
- 改错题_103
- poj 3253 Fence Repair(Huffman问题,优先队列priority_queue)
- iOS图片拉伸技巧—— resizableImageWithCapInsets
- Linux 学习笔记 -- 第二部分 Linux 文件、目录与磁盘格式 -- 第8章 Linux 磁盘与文件系统管理
- 用maven命令导入项目到svn服务器
- 改错题_105