嵌入式web服务器boa的测试
来源:互联网 发布:淘宝品控违规怎么处理 编辑:程序博客网 时间:2024/05/20 21:19
在移动互联网的时代,我们希望通过internet控制手持终端设备,故而手持设备上运行轻型、占用内存小的web服务器成为必要的选择。
本学期想要通过zedboard实现开发一款机器人,主要通过手机客户端或者电脑进行控制。想到移植web服务器到zedboard,通过web页面或则客户端进行控制。
我使用嵌入式boa服务器,其下载地址如下:boa
下载boa-0.94.13.tar.gz解压缩文件:
tar xvzf boa-0.94.13.tar.gz进入目录boa-0.94.13/src,执行脚本./configure生成Makefile文件。
我们本次在本机测试,默认即可,不需要对Makefile进行修改。
如果要移植到zedboard,需要修改Makefile文件。修改其中的CC=arm-xilinx-linux-gnueabi-gcc CPP=arm-xilinx-linux-gnueabi-g++
接下来,我们需要对boa.c做一小小的改动,vim打开boa.c,找到225~227行,注释掉这三行,然后保存退出。
/*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,在当前的src目录下就会生成可执行文件boa。
接下来,我们对boa服务器进行配置。
回到源文件下,找到boa.conf,打开此文件进行配置。需要修改的几个地方如下:
User nobodyGroup nogroup改为User 0Group 0
DocumentRoot /var/www/boa #定义html文件的主目录
DirectoryIndex index.html #默认的html访问文件
ScriptAlias /cgi-bin/ /var/www/boa/cgi-bin/ #输入站点cgi程序位置配置好的boa.conf如下:
Port 80# Listen: the Internet address to bind(2) to. If you leave it out,# it takes the behavior before 0.93.17.2, which is to bind to all# addresses (INADDR_ANY). You only get one "Listen" directive,# if you want service on multiple IP addresses, you have three choices:# 1. Run boa without a "Listen" directive# a. All addresses are treated the same; makes sense if the addresses# are localhost, ppp, and eth0.# b. Use the VirtualHost directive below to point requests to different# files. Should be good for a very large number of addresses (web# hosting clients).# 2. Run one copy of boa per IP address, each has its own configuration# with a "Listen" directive. No big deal up to a few tens of addresses.# Nice separation between clients.# The name you provide gets run through inet_aton(3), so you have to use dotted# quad notation. This configuration is too important to trust some DNS.#Listen 192.68.0.5# User: The name or UID the server should run as.# Group: The group name or GID the server should run as.#User nobody#Group nogroupUser 0Group 0# ServerAdmin: The email address where server problems should be sent.# Note: this is not currently used, except as an environment variable# for CGIs.#ServerAdmin root@localhost# ErrorLog: The location of the error log file. If this does not start# with /, it is considered relative to the server root.# Set to /dev/null if you don't want errors logged.# If unset, defaults to /dev/stderrErrorLog /var/log/boa/error_log# Please NOTE: Sending the logs to a pipe ('|'), as shown below,# is somewhat experimental and might fail under heavy load.# "Usual libc implementations of printf will stall the whole# process if the receiving end of a pipe stops reading."#ErrorLog "|/usr/sbin/cronolog --symlink=/var/log/boa/error_log /var/log/boa/error-%Y%m%d.log"# AccessLog: The location of the access log file. If this does not# start with /, it is considered relative to the server root.# Comment out or set to /dev/null (less effective) to disable # Access logging.AccessLog /var/log/boa/access_log# Please NOTE: Sending the logs to a pipe ('|'), as shown below,# is somewhat experimental and might fail under heavy load.# "Usual libc implementations of printf will stall the whole# process if the receiving end of a pipe stops reading."#AccessLog "|/usr/sbin/cronolog --symlink=/var/log/boa/access_log /var/log/boa/access-%Y%m%d.log"# UseLocaltime: Logical switch. Uncomment to use localtime # instead of UTC time#UseLocaltime# VerboseCGILogs: this is just a logical switch.# It simply notes the start and stop times of cgis in the error log# Comment out to disable.#VerboseCGILogs# ServerName: the name of this server that should be sent back to # clients if different than that returned by gethostname + gethostbyname ServerName www.ballrobot.net# VirtualHost: a logical switch.# Comment out to disable.# Given DocumentRoot /var/www, requests on interface 'A' or IP 'IP-A'# become /var/www/IP-A.# Example: http://localhost/ becomes /var/www/127.0.0.1## Not used until version 0.93.17.2. This "feature" also breaks commonlog# output rules, it prepends the interface number to each access_log line.# You are expected to fix that problem with a postprocessing script.#VirtualHost # DocumentRoot: The root directory of the HTML documents.# Comment out to disable server non user files.DocumentRoot /var/www/boa# UserDir: The name of the directory which is appended onto a user's home# directory if a ~user request is recieved.UserDir public_html# DirectoryIndex: Name of the file to use as a pre-written HTML# directory index. Please MAKE AND USE THESE FILES. On the# fly creation of directory indexes can be _slow_.# Comment out to always use DirectoryMakerDirectoryIndex index.html# DirectoryMaker: Name of program used to create a directory listing.# Comment out to disable directory listings. If both this and# DirectoryIndex are commented out, accessing a directory will give# an error (though accessing files in the directory are still ok).DirectoryMaker /usr/lib/boa/boa_indexer# DirectoryCache: If DirectoryIndex doesn't exist, and DirectoryMaker# has been commented out, the the on-the-fly indexing of Boa can be used# to generate indexes of directories. Be warned that the output is # extremely minimal and can cause delays when slow disks are used.# Note: The DirectoryCache must be writable by the same user/group that # Boa runs as.# DirectoryCache /var/spool/boa/dircache# KeepAliveMax: Number of KeepAlive requests to allow per connection# Comment out, or set to 0 to disable keepalive processingKeepAliveMax 1000# KeepAliveTimeout: seconds to wait before keepalive connection times outKeepAliveTimeout 10# MimeTypes: This is the file that is used to generate mime type pairs# and Content-Type fields for boa.# Set to /dev/null if you do not want to load a mime types file.# Do *not* comment out (better use AddType!)MimeTypes /etc/mime.types# DefaultType: MIME type used if the file extension is unknown, or there# is no file extension.DefaultType text/plain# CGIPath: The value of the $PATH environment variable given to CGI progs.CGIPath /bin:/usr/bin:/usr/local/bin# SinglePostLimit: The maximum allowable number of bytes in # a single POST. Default is normally 1MB.# AddType: adds types without editing mime.types# Example: AddType type extension [extension ...]# Uncomment the next line if you want .cgi files to execute from anywhere#AddType application/x-httpd-cgi cgi# Redirect, Alias, and ScriptAlias all have the same semantics -- they# match the beginning of a request and take appropriate action. Use# Redirect for other servers, Alias for the same server, and ScriptAlias# to enable directories for script execution.# Redirect allows you to tell clients about documents which used to exist in# your server's namespace, but do not anymore. This allows you to tell the# clients where to look for the relocated document.# Example: Redirect /bar http://elsewhere/feh/bar# Aliases: Aliases one path to another.# Example: Alias /path1/bar /path2/fooAlias /doc /usr/doc# ScriptAlias: Maps a virtual path to a directory for serving scripts# Example: ScriptAlias /htbin/ /www/htbin/ScriptAlias /cgi-bin/ /var/www/boa/cgi-bin/
然后执行如下命令:
mkdir /etc/boamkdir /var/www/boamkdir /var/www/boa/cgi-bincp {编译boa的路径}/src/boa /etc/boacp {编译boa的路径}/src/boa /sbin #方便boa启动cp {编译boa的路径}/boa.conf /etc/boa
cp /etc/mime.typs /etc/boacp /etc/boa/* /var/www/boa/ -rf这里需要注意的是,boa服务器默认的启动路径为/etc/boa,所以一定要在/etc/目录下建立boa文件夹,并将boa、boa.conf、mime.types三个文件复制到此目录下。
同理移植到zedboard上同样需要这样。
完成以上步骤后,我们在/var/www/boa/目录下新建index.html。
<html><head>
<title>Boa local test</title>
</head>
<body>
<test>hello codeworld!!!</test>
<p><a href="./cgi-bin/a.out">cgi in the boa server</a></p>
</body>
</html>
在/var/www/boa/cgi-bin目录下建立cgi测试程序:
#include <stdio.h>
int main()
{
printf("Content-Type:text/html\r\n\r\n");
printf("<html><head>\n");
printf("<title>cgi</title>\n");
printf("</head>\n");
printf("<body>\n");
printf("<hello>OBB-damn it!!!</hello>\n");
printf("<p>this is a demo of cgi in the boa server</p>\n");
printf("<html><head>\n");
return 0;
}
直接gcc cgi-test生成a.out文件。
接下来,我们测试boa服务器。终端键入boa&,后台运行boa服务器。
打开浏览器键入127.0.0.1即可测试
0 0
- 嵌入式web服务器boa的测试
- 嵌入式WEB服务器BOA的移植方法
- 嵌入式WEB服务器BOA的移植方法
- 嵌入式web服务器boa的编译移植
- 嵌入式WEB服务器BOA的移植方法
- 嵌入式web服务器Boa的移植
- 嵌入式web服务器boa的编译移植
- 嵌入式linux web服务器boa的移植方法/arm开发板linux嵌入式web服务器boa
- 嵌入式web入门:boa服务器移植到简单cgi测试
- 嵌入式web入门:boa服务器移植到简单cgi测试
- ubuntu下BOA服务器的建立以及arm开发板linux嵌入式web服务器boa
- 嵌入式WEB服务器BOA的移植方法(一)
- 嵌入式WEB服务器BOA的移植方法(三)
- 嵌入式WEB服务器BOA的移植方法(二)
- 嵌入式Web 服务器Boa 的移植及其应用
- 嵌入式WEB服务器BOA的移植方法211034328
- 嵌入式Web服务器Boa的移植及其应用
- 嵌入式WEB服务器移植三部曲之BOA的移植
- 无线路由找不到无线网络的原因
- BI工具:tableau桌面版 视频学习笔记(二、分析)
- js实现表单项的全选、反选以及删除操作
- block写法
- 模式设计相关网站
- 嵌入式web服务器boa的测试
- NS2中几个重要的类
- Android源码编译整理总结
- javascript 连接数据库
- 虚函数与继承调用
- Linux 信号signal处理机制
- php把数组写入文件
- jni ndk-build编译成静态库时一闪而过解决办法
- 使用 Google Analytics 对 iPhone/iPad 应用进行统计和分析