当前位置:网站首页>Migration of BOA Server
Migration of BOA Server
2022-08-03 06:32:00 【Certainly is food package】
概述
BOA是一种非常小巧的web服务器,Used to handle client-side or browser-sidehttp请求,Because of its small size,性能优秀,Therefore, it is suitable for embedded systems.
BOA简介
其可执行代码只有大约60KB左右,Boais a single taskHTTP服务器,Boa只能依次完成用户的请求,而不会fork出新的进程来处理并发连接请求.Boa支持CGI.
Boa的设计目标是速度和安全.(CGI只是一个进程,用来提供接口),Automatic directory generation and automatic file guns for stitching.
BoaThe main design goals are speed and safety.安全性在“Cannot be destroyed by malicious users”的意义上,不是“Fine-grained access control and encrypted communications”.
特点:可靠性和可移植性,BoaNot as a powerful server.
开发平台:GNU / Linuxis the current development platform.
BOA移植过程
- 下载boa源码,本文使用的是
1.进入boa官网下载
http://www.boa.org/
2.CSDN直接下载
https://download.csdn.net/download/qq_42368385/86267519
- 解压文件,并进入./boa-0.94.13/src目录
cd ./boa-0.94.13/src/
- 执行./configure配置编译环境
[email protected]:~/boa-0.94.13/src$ ./configure
- make编译源码
[email protected]:~/boa-0.94.13/src$ make
make编译会出现错误:
compat.h:120:30: note: in definition of macro ‘TIMEZONE_OFFSET’
#define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff
^
make: *** [util.o] Error 1
解决方法:
(1)修改compat.h 的第120行代码
(2)修改boa.c 的第225行代码
[email protected]:~/boa-0.94.13/src$ vim compat.h +120
将
#define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff
改成:
#define TIMEZONE_OFFSET(foo) (foo)->tm_gmtoff
[email protected]:~/boa-0.94.13/src$ vim boa.c +225
Comment out these lines of code:
if (setuid(0) != -1) {
DIE("icky Linux kernel bug!");
}
改为:
#if 0 //注释掉
if (setuid(0) != -1) {
DIE("icky Linux kernel bug!");
}
#endif
Check out the file you just compiled,重新编译
[email protected]:~/boa-0.94.13/src$ make clean
[email protected]:~/boa-0.94.13/src$ make
5.创建boa安装目录 /boa
mkdir -p /home/linux/boa /home/linux/boa/www /home/linux/boa/cgi-bin /home/linux/boa/log
6.Copy the one generated by the previous compilationboa file to createboa文件夹下,修改boa-0.94.13文件夹下的defines.h文件中的SERVER_ROOT,Make it point to the file path created earlier
[email protected]:~/boa-0.94.13/src$ sudo cp boa /home/linux/boa/
[email protected]:~/boa-0.94.13/src$ vi defines.h +30
将第30行:
#define SERVER_ROOT "/etc/boa"
The specified path is changed to the file path created earlier:
#define SERVER_ROOT "/home/linux/boa"
7.Copy the necessary files to the installation directory
[email protected]:~/boa-0.94.13/src$ cp boa /home/linux/boa/
[email protected]:~/boa-0.94.13/src$ cp boa_indexer /home/linux/boa/
[email protected]:~/boa-0.94.13/src$ cp /etc/mime.types /home/linux/boa/
[email protected]:~/boa-0.94.13/src$ cd ..
[email protected]:~/boa-0.94.13$ cp boa.conf /home/linux/boa/
8.修改boa配置文件
[email protected]:~/boa$ ls
boa boa.conf boa_indexer cgi-bin log mime.types www
[email protected]:~/boa$ cp boa.conf boa.conf.back
[email protected]:~/boa$ cat boa.conf.back | grep -v "#" | grep -v "^$" > boa.conf
[email protected]:~/boa$ vim boa.conf
将内容改为:
Port 80
User 0
Group 0
ErrorLog /home/linux/boa/log/error_log
AccessLog /home/linux/boa/log/access_log
DocumentRoot /home/linux/boa/www
UserDir public_html
DirectoryIndex index.html
DirectoryMaker /home/linux/boa/boa_indexer
KeepAliveMax 1000
KeepAliveTimeout 10
MimeTypes /home/linux/boa/mime.types
DefaultType text/plain
CGIPath /bin:/usr/bin:/usr/local/bin
Alias /doc /usr/doc
ScriptAlias /cgi-bin/ /home/linux/boa/cgi-bin/
9.index.html页面的实现
[email protected]:~/boa$ cd www/
[email protected]:~/boa/www$ vi index.html
在index.html中添加以下内容
<html>
<body>
<h3>this is a test!</h3><br/>
<img src="image.jpg"/>
<h3>tree picture</h3><br/>
<a href="/cgi-bin/test.cgi">to cgi page</a>
</body>
</html>
Find a picture to put it withindex.html的同级目录下
10.测试用的test.cgi生成
[email protected]:~/boa$ cd cgi-bin/
[email protected]:~/boa/cgi-bin$ vi test.c
添加以下内容:
#include <stdio.h>
int main()
{
printf("Content-type:text/html\n\n"); //这句一定要加上
printf("<html><body>");
printf("<font style=\"color:red; font-size:30px;\">Hello, CGI!</font><br/>");
printf("<a href=\"/index.html\">return index.html</a>");
printf("</body></html>");
return 0;
}
编译生成test.cgi
[email protected]:~/boa/cgi-bin$ gcc -o test.cgi test.c
[email protected]:~/boa/cgi-bin$ ls
test.c test.cgi
11.查看目录
[email protected]:~/boa$ tree
.
├── boa
├── boa.conf
├── boa.conf.back
├── boa_indexer
├── cgi-bin
│ ├── test.c
│ └── test.cgi
├── log
├── mime.types
└── www
├── core
├── image.jpg
└── index.html
3 directories, 10 files
12.验证效果
[email protected]:~/boa$ ./boa
然后打开浏览器输入127.0.0.1Do a loopback test
就会出现这样的效果
注意:如果出现其他错误,Check if there is any problem with the path,出现make,拷贝boa文件过来
边栏推荐
猜你喜欢
随机推荐
MySql的Sql语句的练习(试试你能写出来几道呢)
ZEMAX | 探索 OpticStudio中的序列模式
ue4入门学习笔记1(操作界面)
二分查找3 - 猜数字大小
检测微信显示无效头像图片链接
C#切换输入法
3d建模师为什么不建议入行
内网渗透之PPT票据传递攻击(Pass the Ticket)
2. What is the difference between Exception and Error?
Oracle 11g静默安装
Unity Animation从UAS获取动画资产到编制状态机控制简单的人物动画
权限管理 UGO 、 ACL 、特殊权限
五、int和Integer有什么区别?
servlet学习(七)ServletContext
使用JSP实现简单的登录注册功能,并且使用Session跟踪用户登录信息
【个人总结】MES系统开发/管理要点
数组与字符串8-最长回文子串
ZEMAX | 如何使用渐晕系数
What is parametric design, let's understand it through practical operation?| SOLIDWORKS How-To Videos
【面试】摸鱼快看:关于selenium/ui自动化的面试题