ubuntu-22.04 BOA服务器的移植

一、下载及配置BOA服务器

1. 下载安装boa服务器

ubuntu下操作:首先在官网下载BOA服务器的源码:boa-0.94.13.tar.gz版本为0.94.13。

在百度网盘下载

将文件拷贝到主目录下

对其进行解压:

tar xf boa-0.94.13.tar.gz

还要安装必要的工具bison,flex。已安装可忽略。

sudo apt-get install bison flex

否则会出现:
make: yacc:命令未找到
make: *** [y.tab.c] 错误 127。

打开解压出的文件夹,进入src文件夹下

cd boa-0.94.13/src/

2. 修改相关配置文件

修改boa-0.94.13/src/compat.h文件:

vim compat.h +120

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

将其修改为:

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

这是由于本机所使用的交叉编译版本对语句用法的不同。

修改 src/log.c文件

打开log.c注释掉下列语句(29行):

gedit log.c +29

改为

extern char *error_log_name;
extern char *access_log_name;
extern char *cgi_log_name;

否则会出现错误:

/usr/bin/ld: log.o:/home/linux/boa-0.94.13/src/log.c:31: multiple definition of `cgi_log_name'; config.o:/home/linux/boa-0.94.13/src/config.c:63: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:45:boa] 错误 1

打开log.c注释掉下列语句(72行):

vim log.c +72

改为

/*if (dup2(error_log, STDERR_FILENO) == -1) {
        DIE("unable to dup2 the error log");
  }*/

否则会出现错误:
log.c:73 unable to dup2 the error log:bad file descriptor。

(可选)修改src/boa.c文件

打开src/boa.c注释掉下面两句话:

vim boa.c +210

修改为----arm这段要注释,x86不用

#if 1 
       if (passwdbuf == NULL) {
       DIE(”getpwuid”);
       }
       if (initgroups(passwdbuf->pw_name, passwdbuf->pw_gid) == -1) {
       DIE(”initgroups”);
       }
#endif

否则会出现错误:

boa.c:211 - getpwuid: No such file or directory。

打开

vim boa.c +225

修改为

#if 0
     if (setuid(0) != -1) {
             DIE(”icky Linux kernel bug!);
    }
#endif

否则会出现问题:

boa.c:228 - icky Linux kernel bug!: No such file or directory。

修改src/defines.h文件

vim defines.h +30

#define SERVER_ROOT "/etc/boa" 修改为 #define SERVER_ROOT "/boa"

3. 生成boa可执行文件

进入相关目录生成makefile文件:

cd ~/boa-0.94.13/src/
./configure

–prefix --host

(可选)修改makefile文件 ---- 对应平台修改

gedit Makefile +31

修改为----arm-linux- 为arm平台

CC = gcc 
CPP = gcc -E 
#CC = arm-linux-gcc 
#CPP = arm-linux-gcc -E 

编译及瘦身

接下来进行编译。

make

然后为刚刚生成的二进制文件boa瘦身删除其调试信息。

x86

strip boa

arm

arm-none-linux-gnueabi-strip boa

创建新目录

sudo mkdir -p /boa /boa/www /boa/cgi-bin /boa/log

查看文件夹

tree /boa

复制一些文件到/boa目录下

[此时位置在~/boa-0.94.13/src 里]

sudo cp boa /boa
sudo cp boa_indexer /boa

复制 /boa-0.94.13 目录下的 boa.conf

sudo cp ../boa.conf /boa

复制 /etc目录下的 mime.types

sudo cp /etc/mime.types /boa

进入/boa 目录里修改 boa.conf 配置文件 需要管理员权限进行修改

cd /boa

4. 修改配置

进入/boa 目录里修改 boa.conf 配置文件

[此时位置在/boa 里]

sudo vim boa.conf

Port端口号(25行)

Port 80 修改为 Port 8080

User程序所属的用户(48行)

User nobody 修改为 User 0

Group程序所属的组(49行)

Group nogroup 修改为 Group 0

ErrorLog(62行)

ErrorLog /var/log/boa/error_log 修改为 ErrorLog /boa/log/error_log

AccessLog(74行)

AccessLog /var/log/boa/access_log 修改为 AccessLog /boa/log/access_log

在SD卡相应位置建立同名文件夹以存放日志文件,否则提示找不到文件夹,这里不用log功能就注释掉。

否则会出现错误提示:“unable to dup2 the error log: Bad file descriptor”

(可选)ServerName(94行)//kankan

#ServerName www.your.org.here 修改为 ServerName www.your.org.here

否则会出现错误“gethostbyname::No such file or directory”

DocumentRoot(111行)

DoucmentRoot /var/www 修改为 DoucmentRoot /boa/www

这里是服务器初始网页放置的位置同样需要在SD卡同样的位置建立同样的文件夹并将名为index.html的网页放置在其中。

DirectoryMaker(130行)

DirectoryMaker /usr/lib/boa/boa_indexer 修改为 DirectoryMaker /boa/boa_indexer

MimeTypes(155行)

MimeTypes /etc/mime.types 修改为 MimeTypes /boa/mime.types

ScriptAlias(193行)

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 修改为 ScriptAlias /cgi-bin/ /boa/cgi-bin/

这里是配置服务器读取cgi程序的目录,需要在SD卡中同样的位置建立同样的目录。

[保存退出]

修改boa 文件夹权限

sudo chmod 777 /boa -R

二、 测试服务器动态网页功能

在/boa/www 下新建一个文件 index.html

cd /boa/www
touch index.html
gedit index.html

按 i 进行编辑,添加如下内容

<HTML>
	<HEAD>
		<TITLE>Hello World</TITLE>
	</HEAD>
		<BODY>
			Hello,my world!
		</BODY>
</HTML>

运行

cd /boa
sudo ./boa
  • 17
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值