Boa服务器 | Ubuntu下编译、安装Boa

目录

1.系统

2.下载

3.编译、安装

4.测试

5.参考


1.系统

[fly@fly-vm boa]$ uname -a
Linux fly-vm 4.15.0-142-generic #146~16.04.1-Ubuntu SMP Tue Apr 13 09:27:15 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

2.下载

官网:http://www.boa.org/

### 下载最新发布版代码
[fly@fly-vm boa]$ wget http://www.boa.org/boa-0.94.13.tar.gz

3.编译、安装

[fly@fly-vm boa]$ tar -zxvf boa-0.94.13.tar.gz
[fly@fly-vm boa]$ cd boa-0.94.13/src/
[fly@fly-vm src]$ ./configure --prefix=$PWD/_install
[fly@fly-vm src]$ make

make出现如下错误

gcc  -g -O2 -pipe -Wall -I.   -c -o util.o util.c
In file included from boa.h:50:0,
                 from util.c:26:
util.c: In function ‘get_commonlog_time’:
util.c:100:39: error: pasting "t" and "->" does not give a valid preprocessing token
         time_offset = TIMEZONE_OFFSET(t);
                                       ^
compat.h:120:30: note: in definition of macro ‘TIMEZONE_OFFSET’
 #define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff
                              ^
: recipe for target 'util.o' failed
make: *** [util.o] Error 1

修改以上两处地方,然后make clean后,重新make编译

在boa-0.94.13/src目录下,新建install.mk文件,使用Makefile命令install和uninstall安装和卸载软件及软件配置信息:

.PHONY: all install uninstall test

SRC_PWD 	= $(PWD)
SUDO		= sudo
MKDIR		= mkdir -p
CP			= cp -rf
RM			= rm -rf 

BIN_BOA		= boa
BIN_INDEX 	= boa_indexer

CONF_FILE 	= ../boa.conf 

DIR_CONF	= /etc/boa
DIR_LOG		= /var/log/boa
DIR_ROOT	= /var/wwwBoa
DIR_MAKER	= /usr/lib/boa
DIR_CGI		= /var/wwwBoa/cgi-bin

all:install

install:
	@echo "Install boa."
	$(SUDO) $(MKDIR) $(DIR_CONF) $(DIR_LOG) $(DIR_ROOT) $(DIR_MAKER) $(DIR_CGI) && \
		$(SUDO) $(CP) $(SRC_PWD)/$(CONF_FILE) $(DIR_CONF) && \
		$(SUDO) $(CP) $(SRC_PWD)/$(BIN_BOA) /usr/bin && \
		$(SUDO) $(CP) $(SRC_PWD)/$(BIN_INDEX) $(DIR_MAKER) && \
		$(SUDO) $(CP) $(SRC_PWD)/../examples/index.html $(DIR_ROOT)

uninstall:
	@echo "Uninstall boa."
	$(SUDO) $(RM) /usr/bin/boa
	$(SUDO) $(RM) $(DIR_CONF)
	$(SUDO) $(RM) $(DIR_LOG)
	$(SUDO) $(RM) $(DIR_ROOT)
	$(SUDO) $(RM) $(DIR_MAKER)

test:
	@echo "-------This is a Test.---------"
	@echo $(SRC_PWD)

编译后安装:

[fly@fly-vm src]$ make -f install.mk install
Install boa.
sudo mkdir -p /etc/boa /var/log/boa /var/wwwBoa /usr/lib/boa /var/wwwBoa/cgi-bin && \
        sudo cp -rf /home/fly/workSpace/boa/gitee/boa-0.94.13/src/../boa.conf  /etc/boa && \
        sudo cp -rf /home/fly/workSpace/boa/gitee/boa-0.94.13/src/boa /usr/bin && \
        sudo cp -rf /home/fly/workSpace/boa/gitee/boa-0.94.13/src/boa_indexer /usr/lib/boa && \
        sudo cp -rf /home/fly/workSpace/boa/gitee/boa-0.94.13/src/../examples/index.html /var/wwwBoa

运行(报错):

[fly@fly-vm ~]$ boa
[12/Jun/2021:01:16:39 +0000] log.c:73 - unable to dup2 the error log: Bad file descriptor

修改如下地方:

Boa服务器 | Ubuntu下编译、安装Boa_第1张图片

重新编译后安装运行(运行成功,可以查看进程PID是5458,通讯端口号是8080):

[fly@fly-vm ~]$ sudo boa
[12/Jun/2021:01:23:11 +0000] boa: server version Boa/0.94.13
[12/Jun/2021:01:23:11 +0000] boa: server built Jun 12 2021 at 09:21:40.
[fly@fly-vm ~]$ [12/Jun/2021:01:23:11 +0000] boa: starting server pid=5458, port 8080

[fly@fly-vm ~]$ nmap localhost

Starting Nmap 7.01 ( https://nmap.org ) at 2021-06-12 09:23 CST
[12/Jun/2021:01:23:24 +0000] request from 127.0.0.1 "(null)" ("(null)"): header read: Connection reset by peer
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00018s latency).
Not shown: 993 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
111/tcp  open  rpcbind
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
631/tcp  open  ipp
2049/tcp open  nfs
8080/tcp open  http-proxy

Nmap done: 1 IP address (1 host up) scanned in 0.08 seconds

4.测试



    
        
        Flyer
    
    
        

This is a Test.

Hello , Wolrd.

在浏览器地址栏输入地址访问:http://192.168.1.132:8080/

Boa服务器 | Ubuntu下编译、安装Boa_第2张图片

5.参考

5.1 BOA服务器移植

5.2 boa服务器之boa.conf文件的基本配置详解

5.3 boa项目代码Gitee仓库地址

你可能感兴趣的:(3.Linux系统使用,4.Linux,C编程,1.C/C++编程,boa,webserver)