分享

boa代码学习笔记2

 lchjczw 2012-12-26

 总觉得对boa感觉依然很陌生,所以,静下心来读box.txt,学到一下几点:

1,Boa is a single-tasking HTTP server.That means that unlike traditional web servers, it does not fork(创建子线程) for each incoming connection, nor does it fork many copies of itself to handle multiple connections.  It internally multiplexes all of the ongoing HTTP connections, and forks only for CGI programs (which must be separate processes), automatic directory generation, and automatic file gunzipping.  Preliminary tests show Boa is capable of handling several thousand hits per second on a 300 MHz Pentium and dozens of hits per second on a lowly 20 MHz 386/SX.意思是说,boa是一个单任务的http 服务器,它不会为每一次的http 连接创建子线程,它只为CGI程序创建子线程,而这些CGI程序必须是分开处理的;文件传输时,能够自动的进行目录生成和解压缩。前人的测试表明,Boa能在一秒内处理几千个hits(不知道怎么翻译,奶奶的)。

2,编译(Build)过程。

cd src   //进入到src文件夹下。

(可选) Change the default SERVER_ROOT by setting the #define at the top of src/defines.h  //配置SERVER_ROOT 路径,不过我暂时还没搞明白,配置成为什么东西合适,等弄明白了,将这里补上。

./configure

make

3,设置用户和端口号

端口号一般设为:80,userid可以是nobody,为了安全,用户可以指定一个user。如果你(user)的权限不是根用户的权限的话,你将不能使用小于1024的端口号,你也不能改变用户。

4,选择一个root sever

在指定的这个root server目录下,必须有conf目录,而且这个目录中,应该有一份 boa.conf文件的拷贝。

5,选择logs输出的目录。

6,设置mime.types文件的路径,编辑boa.conf文件,进行更多的设置。

7,启动boa。使用Start Boa来启动boa。如果SERVER_ROOT没有被正确的编译到二进制中,可以使用-c来修改,例如:./boa -c /usr/local/boa。

8,关于一些文件的一点说明:

boa.conf:是boa唯一的配置文件,文件中所使用的指令,在DIRECTIVES 部分定义。(where?)The Boa configuration file is parsed with a lex/yacc or flex/bison generated parser.

mime.types:定义了Boa将要发送的内容类型在协议 HTTP/1.0 or better transaction(这个不知道怎么翻译)。Set to /dev/null if you do not want to load a mime types file.(好像没发现有这个文件)。

9,详解boa.conf文件中使用的常见指令

---Port <Integer> 默认是80,如果要使用小于1024的端口好,用户必须具有根权限。

---Listen <IP>  ip表示将要被绑定的ip地址,如果省略的话,表示可以绑定所有的地址。

---You only get one "Listen" directive,  if you want service on multiple IP addresses, you have three choices:(多地址上同时使用,有三种选择):

a,All addresses are treated the same; makes sense if the addresses are localhost, ppp, and eth0.

b,se the VirtualHost directive below to point requests to different files.Should be good for a very large number of addresses (web hosting clients).

c,Each instance has its own configuration with its own "Listen" directive.  No big deal up to a few tens of addresses. Nice separation between clients.(boa.texi 280行,明天继续)

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多