本测试在ubuntu1304下测试,具体步骤如下:

1下载源码:www.boa.org,可在ubuntu下自带的火狐浏览器下载,也可在window下下载,然后再移到ubuntu下;

2打开终端,将boa解压到某目录并进入当前源码目录

tar xvzf boa-*

cd /boa-0.94.13/src

3配置 ./configure

4编译

make

出现:yacc -d boa_grammar.y

make: yacc: Command not found

make: *** [y.tab.c] Error 127

分析:yacc是一个文法分析器的生成器,bison即是yacc的GNU版本.Lex和YACC是用于构造词法分析机和语法解释器的工具,利用Lex和

YACC你可以轻松的构造一个语法解释器。

解决:apt-get install bison

再make

出现:lex boa_lexer.l

     make: lex: Command not found

make: *** [lex.yy.c] Error 127

解决:apt-get install flex

再make

出现:util.c:100:1: error: pasting "t" and "->" does not give a valid preprocessing token

make: *** [util.o] Error 1

解决: 修改 src/compat.h

找到 #define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff

修改成 #define TIMEZONE_OFFSET(foo) (foo)->tm_gmtoff

再make,编译通过,在当前目录生成一boa可执行程序

5 复制boa.conf到/etc/boa目录下,如果没有这个目录,自己手动创建 : sudo mkdir /etc/boa

因为在defines.h文件中,

当然也可修改此设置,在此选择默认。

6 执行./boa

出现: log.c:73 unable to dup2 the error log: Bad file descriptor

解决:注释掉:

if(dup2(error_log, STDERR_FILENO) == -1)

{   

  DIE("unable to dup2 the error log");

}

执行make,

再次执行./boa

出现:Cannot open /var/log/boa/access_log for logging: logfile

open: No such file or directory,

或者:Cannot open/var/log/boa/error_log for logging: logfile

open: No such file or directory

解决:

哪个出现,你就在boa.conf里把它给注释掉(不要忘了/etc/boa/目录下的boa.conf)

即改成:

#AccessLog /var/log/boa/access_log

再次执行./boa

此时boa服务器就已经启动!

测试1:

将index.html文件存放在/var/www/下(如果没有,则创建)

打开浏览器,输入ubuntu下的IP地址,则显示如下结果:

实例代码1:

index.html

 <html>
<head><title>boa web test page</title></head>
<body bgcolor=#666666>
<p><hr/></p>
<p><center>my boa main page</center></p)
<p><hr/></p>
<p>Boa is a tiny web server that also offers extremely high performance.
It is specifically designed to run on UNIX-like systems, which includes Linux, as well as the *BSD systems. To get all the legal stuff out of the way, Boa is available for free and is covered by the GNU Public License (GPL).The source code for Boa, as well as documentation, can be found at http://www.boa.org/.</p>
<p><hr/></p> </body>
</html>

测试2:

将自己制作的网页(hello.html)放到/var/www/目录中,将cgi程序放到/var/www/cgi-bin目录下,在浏览器中输入http://192.168.182.153/hello.html,这里的IP地址就是Linux的IP地址。则出现如下结果:

实例代码2:

hello.html

 <html>
<head>
<title>this is my first HTML page</title>
</head> <body>
<center><p><h1>this is is a simple test of <I>HTML</I></h1></p></center>
<center><img src=../../"img/logo.jpg" alt="CST studio" />
hello from <a href=../../"http://www.latelee.org"><b>Late Lee</b></a></center> <br /> <center><p>you can visit my website at <a href = "http://www.latelee.org">www.latelee.org</a></p><center>
<hr /> <!-- a test -->
<form name="form1" action="/cgi-bin/hello.cgi" method="post">
<table align="center">
<tr><td align="center" colspan="2"></td></tr>
<tr>
<td align="center">user name</td>
<td><input type="text" name="Username"></td>
</tr> <tr>
<td align="center">password</td>
<td><input type="password" name="Password"></td>
</tr> <tr>
<td><input type="submit" value="login"></td>
<td><input type="reset" value="cancel"></td>
</tr>
</table>
</form>
</body> </html>

hello.c

 #include <stdlib.h>
#include <stdio.h>
#include <string.h> char* get_cgi_data(FILE* fp, char* method)
{
char* input;
int len;
int size=;
int i=; if (strcmp(method, "GET") == ) /**< GET method */
{
input = getenv("QUERY_STRING");
return input;
} else if (strcmp(method, "POST") == ) /**< POST method */
{
len = atoi(getenv("CONTENT_LENGTH"));
input = (char*)malloc(sizeof(char) * (size+)); if (len == )
{
input[] = ' ';
return input;
} while ()
{
input[i] = (char)fgetc(fp);
if (i == size)
{
input[i+] = ' ';
return input;
}
--len; if (feof(fp) || (!(len)))
{
i++;
input[i] = ' ';
return input;
}
i++;
}
}
return NULL;
} int main(void)
{
char* input;
char* method;
char name[];
char passwd[];
int i=;
int j=; printf("Content-type:text/htmlnn");
printf("The following is query result:");
method = getenv("REQUEST_METHOD");
input = get_cgi_data(stdin, method); printf("string is: %s", input);
int len = strlen(input);
/* sizeof("username=") = 9 */
for (i=; i<len; i++)
{
if (input[i] == '&')
{
name[j]=' ';
break;
} name[j++]=input[i];
} /* sizeof("username=")+sizeof(&password=) = 19 */
for (i=+strlen(name),j=; i<(int)strlen(input); i++)
{
passwd[j++] = input[i];
}
passwd[j]=' '; printf("your username is %s your password is %sn", name, passwd); return ;
}

参考文献:

1 在ubuntu上运行boa的方法

2 Linux下小型WEB服务器boa的使用

ubuntu1304下安装boa服务器的更多相关文章

  1. Linux下安装Tomcat服务器和部署Web应用

    一.上传Tomcat服务器

  2. 转】Linux下安装Tomcat服务器和部署Web应用

    原博文出自于: http://www.cnblogs.com/xdp-gacl/p/4097608.html 感谢! 一.上传Tomcat服务器

  3. 如何在Windows下安装Tomcat服务器

    Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP 程序的首选服务器.在Windows下安装 ...

  4. JavaWeb入门——在Linux环境下安装Tomcat服务器

    JavaWeb入门——在Linux环境下安装Tomcat服务器 摘要:本文主要学习了如何在Linux环境下安装Tomcat服务器. 准备工作 检查Java环境变量 检查系统是否配置了Java的环境变量 ...

  5. JavaWeb入门——在Windows环境下安装Tomcat服务器

    JavaWeb入门——在Windows环境下安装Tomcat服务器 摘要:本文主要学习如何在Windows环境中下载并安装Tomcat服务器. 下载 获取安装包 推荐去官网上下载Tomcat: htt ...

  6. Linux 下安装 Tomcat 服务器和部署 Web 应用

    一.上传Tomcat服务器 二.安装Tomcat服务器 2.1.解压tomcat服务器压缩包 2.2.配置环境变量 tomcat服务器运行时是需要JDK支持的,所以必须配置好JDK用到的那些环境变量 ...

  7. Linux下安装Tomcat服务器

    Linux下安装Tomcat服务器 一.总结 一句话总结: linux多用才能熟 1.阿里云上面我们买的服务器,怎么让它可以访问特定的端口? 就是给服务器的安全组添加规则:实例-->更多--&g ...

  8. 如何在linux下安装tomcat服务器

    linux作为现在比较主流的服务器操作系统,使用的机器广泛,安全稳定.tomcat作为应用容器当然可以有linux版本的tomcat.在linux上安装tomcat的方式也很简单,只需要运行脚本基本配 ...

  9. 转 Linux下安装Tomcat服务器和部署Web应用

    转载声明: http://www.cnblogs.com/xdp-gacl/p/4097608.html 一.上传Tomcat服务器

随机推荐

  1. myeclipse2014如何添加源码反编译工具插件

    Eclipse下的Java反编译插件:Eclipse Class Decompiler,整合了目前最好的2个Java反编译工具Jad和JD-Core,并且和Eclipse Class Viewer无缝 ...

  2. cocos2d-x3.x使用rapidjson

    rapidjson效率高,所以之前cocostudio里面解析用的jsoncpp也换成了rapidjson. 引擎又带有rapidjson库,所以不用单独去下载,直接就可以用. 这里主要写一下关于解析 ...

  3. 第二节:Maven的运行机制

    Maven 的运行机制分为两个分别是生命周期和插件 首先我们来说说Maven的生命周期 1.1:生命周期是个个阶段组成的 1.2:Maven的生命周期是相互独立的,他们之间没有交集 1.3:阶段是有顺 ...

  4. HTML+CSS实例——漂亮的查询部件(一)

    一.参考网址:www.kuhnsjewelers.com 二.效果: 三.HTML <div id="search-box"> <asp:TextBox ID=& ...

  5. 为什么我要称自己为Javascript程序员

    Aaron Griffin写了一篇精彩的牢骚文章,主要是关于各种框架和它们能把程序员从主要业务编程中抽离出来的功能特征.概括一下他的主要论点,当你成为了一个“Rails程序员”,你使用的是一种易于理解 ...

  6. Linux下VirtualBox出现kernel driver not installed的解决方法

    今天安装好rhel-server-6.6-i386后,再安装VirtualBox成功,但是再VirtualBox中创建虚拟机的时候出现了“不能为xx虚拟机打开新任务” 并弹出如下的错误信息:

  7. SQL Server网络地址备份

    SQL Server网络地址备份 Ø  软件系统: SQL Server 各版本 1.问题描述: 在XX客户做SQL Server 到Oracle 数据迁移时,当时由于客户的SQL Server200 ...

  8. LeetCode 213

    House Robber II Note: This is an extension of House Robber. After robbing those houses on that stree ...

  9. poj 1716 差分约束

    水水的. 给几个不等式:dis[b]-dis[a]>=2;  0<=dis[i+1]-dis[i]<=1; #include<iostream> #include< ...

  10. Android 给应用定制皮肤

    Android 给应用定制皮肤 导读:皮肤也就是相关的资源文件单独放置在某个工程中,一种皮肤一个工程文件.一个工程包括N多的资源文件,多个工程间资源的关系是,文件名,资源ID等完全一样. 在实现程序功 ...