ubuntu1304下安装boa服务器
本测试在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服务器的更多相关文章
- Linux下安装Tomcat服务器和部署Web应用
一.上传Tomcat服务器
- 转】Linux下安装Tomcat服务器和部署Web应用
原博文出自于: http://www.cnblogs.com/xdp-gacl/p/4097608.html 感谢! 一.上传Tomcat服务器
- 如何在Windows下安装Tomcat服务器
Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP 程序的首选服务器.在Windows下安装 ...
- JavaWeb入门——在Linux环境下安装Tomcat服务器
JavaWeb入门——在Linux环境下安装Tomcat服务器 摘要:本文主要学习了如何在Linux环境下安装Tomcat服务器. 准备工作 检查Java环境变量 检查系统是否配置了Java的环境变量 ...
- JavaWeb入门——在Windows环境下安装Tomcat服务器
JavaWeb入门——在Windows环境下安装Tomcat服务器 摘要:本文主要学习如何在Windows环境中下载并安装Tomcat服务器. 下载 获取安装包 推荐去官网上下载Tomcat: htt ...
- Linux 下安装 Tomcat 服务器和部署 Web 应用
一.上传Tomcat服务器 二.安装Tomcat服务器 2.1.解压tomcat服务器压缩包 2.2.配置环境变量 tomcat服务器运行时是需要JDK支持的,所以必须配置好JDK用到的那些环境变量 ...
- Linux下安装Tomcat服务器
Linux下安装Tomcat服务器 一.总结 一句话总结: linux多用才能熟 1.阿里云上面我们买的服务器,怎么让它可以访问特定的端口? 就是给服务器的安全组添加规则:实例-->更多--&g ...
- 如何在linux下安装tomcat服务器
linux作为现在比较主流的服务器操作系统,使用的机器广泛,安全稳定.tomcat作为应用容器当然可以有linux版本的tomcat.在linux上安装tomcat的方式也很简单,只需要运行脚本基本配 ...
- 转 Linux下安装Tomcat服务器和部署Web应用
转载声明: http://www.cnblogs.com/xdp-gacl/p/4097608.html 一.上传Tomcat服务器
随机推荐
- Android(java)学习笔记95:Android原理揭秘系列之View、ViewGroup
作过Android 应用开发的朋友都知道,Android的UI界面都是由View和ViewGroup及其派生类组合而成的.其中,View是所有UI组件的基类,而ViewGroup是容纳这些组件的容器, ...
- C# WinForm 中ComboBox数据绑定的问题 (转)
来自:http://blog.sina.com.cn/s/blog_5fb9e26301013wga.html C# WinForm 中ComboBox数据绑定的问题 怎样让WinForm中的Comb ...
- scrapy_ip_agent
#File name is rotate_useragent# -*- coding: UTF-8 -*- import randomimport urllib2import redisfrom sc ...
- jquery手写焦点轮播图-------解决最后一张无缝跳转第一张的问题
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Java操作zip压缩和解压缩文件工具类
需要用到ant.jar(这里使用的是ant-1.6.5.jar) import java.io.File; import java.io.FileInputStream; import java.io ...
- 【补】【FZU月赛】【20150515】【待续】
A FZU-2054 水题,比较A,B双方的最大值即可. B FZU-2055 string,截取‘.’之前和之后然后和给出的文件夹名和拓展名比较就好了啊,不明白为什么那么多人错. 代码: #incl ...
- poj 1679 次小生成树
次小生成树的求法: 1.Prime法 定义一个二维数组F[i][j]表示点i到点j在最小生成树中的路径上的最大权值.有个知识就是将一条不在最小生成树中的边Edge加入最小生成树时,树中要去掉的边就是E ...
- MVC清除缓存设置+数据验证
[OutputCache(Location = OutputCacheLocation.None, NoStore = true)] [Table("User")]:定义UserD ...
- 【hdu2896】病毒侵袭
题目描述 当太阳的光辉逐渐被月亮遮蔽,世界失去了光明,大地迎来最黑暗的时刻....在这样的时刻,人们却异常兴奋--我们能在有生之年看到500年一遇的世界奇观,那是多么幸福的事儿啊~~但网路上总有那么些 ...
- getBoundingClientRect()兼容性处理
getBoundingClientRect() 这个方法返回一个矩形对象,包含四个属性:left.top.right和bottom.分别表示元素各边与页面上边和左边的距离. var box=docum ...