在arm开发板上部署boa服务器
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
在arm开发板上部署boa服务器
2009-08-20 14:22:12| 分类:编程笔记|字号订阅
里面所有的步骤都确定完成过,但是可能遗漏了一些步骤,有待重部署一次来验证,补充,--------------------------------------一,下载
/
二,解压
# tar xzf boa-0.94.13.tar.gz
三,编译
# cd boa-0.94.13/src
# ./configure
生成了makefile文件,
修改makefile文件,
把其中的
CC CPP
改为:
CC = arm-linux-gcc
CPP = arm-linux-g++
然后make
# make
删除调试信息(可以不做,目的是减小文件大小):
# arm-linux-strip boa
四,修改配置
从boa根目录找到boa.conf文件,
修改如下项目:
User nobody (可以不修改)
Group nogroup 改为:Group 0
ErrorLog /var/log/boa/error_log (错误日志文件)
AccessLog /var/log/boa/access_log (访问日志文件,可以用#注释掉这行,表示不要这个日志)
ServerName (服务器地址)
DocumentRoot /var/www (html文件主路径)
MimeTypes /etc/mime.types (mime.types文件)
更多配置,可以参见:/u1/34076/showart_268366.html
五,配置开发板
1,复制boa的可执行文件到开发板,(如/usr/local/bin/ 目录)
2,在开发板上建文件夹
# mkdir /var/www/ ,并放一个简单的index.html 测试文件进去
# mkdir /var/log/boa ,用来存放access_log error_log
3,复制之前修改好的boa.conf文件到/etc/boa/boa.conf
4,复制自己pc(我的是ubuntu)上的mime.types文件,到/etc/mime.types上
六,运行boa
# boa
-----------------------------------------------------------------------------------------------------------------
更多说明:
一,
运行正确以上6步后,
应该能通过其它电脑的浏览器,访问到/var/www/index.html页面
二,如果执行时候有错误:
# ./boa
[27/Nov/1990:13:22:25 + 0000]boa.c:266.icky Linux kernel bug!:No such fileBae
将User 0修改成User nobodyBae
三,在板子上方放的cgi程序,html文件,一定要把权限修改对,修改成755
四,一个简单的cgi测试程序:
(来自:/viewthread.php?tid=83&highlight=cgi)
1,html文件:
-------------------------------------<html>
<head>
<title>CGI Testing</title>
</head>
<body>
<table width="200" height="180" border="0" style="font-size:12px">
<tr><td>
<div style="font-weight:bold; font-size:15px">Method: GET</div>
<div>lease input two number:<div>
<form method="get" action="./cgi-bin/get">
<input type="txt" size="3" name="a">+
<input type="txt" size="3" name="b">=
<input type="submit" value="sum">
</form>
</td></tr>
<tr><td>
<div style="font-weight:bold; font-size:15px">Method: POST</div>
<div>lease input two number:<div>
<form method="post" action="./cgi-bin/post">
<input type="txt" size="3" name="m">*
<input type="txt" size="3" name="n">=
<input type="submit" value="resu">
</form>
</td></tr>
<tr><td><inputtype="button" value="Back
Home"onclick='javascript:window.location="./index.html"'></td></tr>
</table>
</body>
</html>
------------------------------
2,get.c :
------------------------------
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char *data;
char a[10],b[10];
printf("Content-Type:text/html\n\n");
printf("<HTML>\n");
printf("<HEAD>\n<TITLE >Get Method</TITLE>\n</HEAD>\n");
printf("<BODY>\n");
printf("<div style=\"font-size:12px\">\n");
data = getenv("QUERY_STRING");
if(sscanf(data,"a=%[^&]&b=%s",a,b)!=2)
{
printf("<DIV STYLE=\"COLOR:RED\">Errorarameters should be entered!</DIV>\n"); }
else
{
printf("<DIV STYLE=\"COLOR:GREEN; font-size:15px;font-weight:bold\">a + b
= %d</DIV>\n",atoi(a)+atoi(b));
}
printf("<HR COLOR=\"blue\" align=\"left\" width=\"100\">");
printf("<input type=\"button\" value=\"Back CGI\"
onclick=\"javascript:window.location='../cgi.html'\">");
printf("</div>\n");
printf("</BODY>\n");
printf("</HTML>\n");
return 0;
}
------------------------------
3,post.c:
------------------------------
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int len;
char *lenstr,poststr[20];
char m[10],n[10];
printf("Content-Type:text/html\n\n");
printf("<HTML>\n");
printf("<HEAD>\n<TITLE >ost Method</TITLE>\n</HEAD>\n");
printf("<BODY>\n");
printf("<div style=\"font-size:12px\">\n");
lenstr=getenv("CONTENT_LENGTH");
if(lenstr == NULL)
{
printf("<DIV STYLE=\"COLOR:RED\">Errorarameters should be entered!</DIV>\n"); }
else
{
len=atoi(lenstr);
fgets(poststr,len+1,stdin);
if(sscanf(poststr,"m=%[^&]&n=%s",m,n)!=2)
{
printf("<DIV STYLE=\"COLOR:RED\">Error: Parameters are not right!</DIV>\n");
}
else
{
printf("<DIV STYLE=\"COLOR:GREEN; font-size:15px;font-weight:bold\">m * n = %d</DIV>\n",atoi(m)*atoi(n));
}
}
printf("<HR COLOR=\"blue\" align=\"left\" width=\"100\">");
printf("<input type=\"button\" value=\"Back CGI\"
onclick=\"javascript:window.location='../cgi.html'\">");
printf("</div>\n");
printf("</BODY>\n");
printf("</HTML>\n");
fflush(stdout);
return 0;
}
------------------------------
4,
把两个c程序编译完成,复制到开发搬上,
通过其它pc访问测试html页面,调用这两个cgi,
其中如果出现:
502 Bad Gateway The CGI was not CGI/1.1 compliant.
错误,
有可能是如下原因:
(1)将.cgi文件拷贝至目标板上后,必须改变其权限chmod 755 *
(2)测试程序中“//“的问题。
参考<Web服务器--Boa实验笔记>
/system/unix/linux/2007-02-07/6888.html
(3)修改BOA 源码cgi.c 添加环境变量:my_add_cgi_env(req, "LD_LIBRARY_PATH", "/lib");(函数complete_env中)再重新交叉编译即可
(4)同时请修改下boa对CGI支持的缺陷。
(5)出现这个问题的原因是关于“库”方面的原因。
如果你编译CGI文件的时候,用静态编译,则编译的时候,会自动地加入库。
arm-linux-gcc -static test.c -o test.cgi
(/t/20061120/13/5171006.html#有相关讨论)
(6) 说它不支持http 1.1 协议,那你在ie中也使用http 1.0协议访问它试试看。
方法是点“工具”->"internet选项“->"高级",把“使用http 1.1协议"前面的勾去掉。
(7)如果是用flashfxp工具传送文件到目标板上,请选用二进制模式传送。
我自己就出错在这里,在此感谢网友newzy帮忙解决这个问题。
(8)对程序进行静态编译,然后再放到板子上,
我在测试中遇到的是权限问题,在测试中,试图向一个文件中写入一条日志,总是出现502这个错误,
修改了这个文件的权限到755 后,可正常运行
5,如果需要以root权限执行boa,
需要修改boa.c中
if (setuid(0) != -1) {
DIE("icky Linux kernel bug!");
去掉这句,
把
boa.conf
中的user 该为root。