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服务器
随机推荐
- Code the Tree
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2292 Accepted: 878 Description A tree ...
- Android(java)学习笔记76:多线程-定时器概述和使用
定时器: 定时器是一个应用十分广泛的线程工具,可用于调度多个定时任务以后台线程的方式执行. 在Java中,可以通过Timer和TimerTask类来实现定义调度的功能 Timer public Tim ...
- SQL Server 2012 performance dashboard 安装
微软提供了一个很好用的工具performance dashboard: 下载地址: http://www.microsoft.com/en-us/download/details.aspx?id=29 ...
- python(1) -文件操作
很多时候我们需要对文件进行一些操作,比如读取并分析日志文件,写入日志文件等等.显然python也内置了对文件进行操作的函数. 读文件: >>> f = open('a.log','r ...
- 【记忆化搜索】Codeforces Round #295 (Div. 2) B - Two Buttons
题意:给你一个数字n,有两种操作:减1或乘2,问最多经过几次操作能变成m: 随后发篇随笔普及下memset函数的初始化问题.自己也是涨了好多姿势. 代码 #include<iostream> ...
- python方式实现scoket通信
要想明白这个网络通信还真的是离不开实现它实现流程图,看明白了大体很多都知道,觉得这个博主画的不错,地址是 http://www.cnblogs.com/wangcq/p/3520400.html 1. ...
- (转载)运行主机管理在openvswitch之上
在这篇文章里介绍了如果运行主机管理在openvswitch之上,而不是单独配置一个物理网卡用于主机管理,并且所有的vm的流量还是通过openvswitch走的. Running Host Manage ...
- 文件加载---理解一个project的第一步
当我最开始写php的时候,总是担心这个问题:我在这儿new的一个class能加载到对应的类文件吗?毕竟一运行就报Fatal Error,什么**文件没找到,类无法实例化等等是一种很“低级”的错误,怕别 ...
- Lombok(1.14.8) - @NoArgsConstructor, @RequiredArgsConstructor & @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor,提供一个无参的构造方法. package com.huey.hello.bean; import java.util.Dat ...
- vs如何新建自己工程的环境变量(局部)和 Windows系统(全局).
来源:http://blog.csdn.net/jtop0/article/details/7574139 在vs2008的Project->Property设置里经常会看到类似$ ...