当前位置: 首页 > 工具软件 > Boa Webserver > 使用案例 >

Linux系统 | ubuntu下编译、运行Boa Web Server

赫连华皓
2023-12-01

1.下载源码(工作目录:Boa_Src):http://www.boa.org/boa-0.94.13.tar.gz

2.解压:tar -xzvf boa-0.94.13.tar.gz

//解压信息
boa-0.94.13/
boa-0.94.13/docs/
boa-0.94.13/docs/Makefile
boa-0.94.13/docs/boa.8
boa-0.94.13/docs/boa.texi
boa-0.94.13/docs/boa_banner.png
boa-0.94.13/CREDITS
boa-0.94.13/ChangeLog
boa-0.94.13/Gnu_License
boa-0.94.13/README
boa-0.94.13/boa.conf
boa-0.94.13/contrib/
boa-0.94.13/contrib/README.chroot.solaris
boa-0.94.13/contrib/redhat/
boa-0.94.13/contrib/redhat/boa.conf
boa-0.94.13/contrib/redhat/boa.init
boa-0.94.13/contrib/redhat/boa.logrotate
boa-0.94.13/contrib/redhat/boa.spec
boa-0.94.13/examples/
boa-0.94.13/examples/cgi-test.cgi
boa-0.94.13/examples/nph-test.cgi
boa-0.94.13/examples/resolver.pl
boa-0.94.13/extras/
boa-0.94.13/extras/alphasort.c
boa-0.94.13/extras/scandir.c
boa-0.94.13/extras/strutil.c
boa-0.94.13/src/
boa-0.94.13/src/.depend
boa-0.94.13/src/Makefile.in
boa-0.94.13/src/acconfig.h
boa-0.94.13/src/aclocal.m4
boa-0.94.13/src/alias.c
boa-0.94.13/src/boa.c
boa-0.94.13/src/boa.h
boa-0.94.13/src/boa_grammar.y
boa-0.94.13/src/boa_lexer.l
boa-0.94.13/src/buffer.c
boa-0.94.13/src/cgi.c
boa-0.94.13/src/cgi_header.c
boa-0.94.13/src/check_struct_for.m4
boa-0.94.13/src/compat.h
boa-0.94.13/src/config.c
boa-0.94.13/src/config.h.in
boa-0.94.13/src/configure
boa-0.94.13/src/configure.in
boa-0.94.13/src/defines.h
boa-0.94.13/src/escape.c
boa-0.94.13/src/escape.h
boa-0.94.13/src/get.c
boa-0.94.13/src/globals.h
boa-0.94.13/src/hash.c
boa-0.94.13/src/index_dir.c
boa-0.94.13/src/ip.c
boa-0.94.13/src/log.c
boa-0.94.13/src/mmap_cache.c
boa-0.94.13/src/parse.h
boa-0.94.13/src/pipe.c
boa-0.94.13/src/queue.c
boa-0.94.13/src/read.c
boa-0.94.13/src/request.c
boa-0.94.13/src/response.c
boa-0.94.13/src/select.c
boa-0.94.13/src/signals.c
boa-0.94.13/src/sublog.c
boa-0.94.13/src/timestamp.c
boa-0.94.13/src/util.c
boa-0.94.13/src/webindex.pl
[fly@fly-vm Boa_Src]$ ls
boa-0.94.13  boa-0.94.13.tar.gz

3.编译:

在src目录下,执行:[fly@fly-vm src]$ ./configure

//配置输出log
creating cache ./config.cache
checking for gunzip... /bin/gunzip
checking for flex... flex
checking for yywrap in -lfl... yes
checking for bison... bison -y
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking how to run the C preprocessor... gcc -E
checking whether make sets ${MAKE}... yes
checking for dirent.h that defines DIR... yes
checking for opendir in -ldir... no
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for fcntl.h... yes
checking for sys/fcntl.h... yes
checking for limits.h... yes
checking for sys/time.h... yes
checking for sys/select.h... yes
checking for getopt.h... yes
checking for working const... yes
checking for uid_t in sys/types.h... yes
checking for pid_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking whether setvbuf arguments are reversed... no
checking for unistd.h... yes
checking for getpagesize... yes
checking for working mmap... yes
checking for getcwd... yes
checking for strdup... yes
checking for strstr... yes
checking for gethostname... yes
checking for gethostbyname... yes
checking for select... yes
checking for socket... yes
checking for inet_aton... yes
checking for scandir... yes
checking for alphasort... yes
checking for tm.tm_gmtoff... yes
checking for tm.tm_zone... yes
checking for sockaddr_in.sin_len... no
checking compile and link profiling code... no
checking whether to compile and link debugging code... yes
checking whether to link with the Dmalloc memory debugger/profiler... no
checking whether to link with the Electric Fence memory debugger... no
updating cache ./config.cache
creating ./config.status
creating Makefile
creating config.h

编译:[fly@fly-vm src]$ make

//编译报错
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
                              ^
<builtin>: recipe for target 'util.o' failed
make: *** [util.o] Error 1

在compat.h文件120行修改如下:

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

在boa.c文件第225行处,注释掉如下部分:

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

在log.c文件72行处,注释掉如下部分:

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

4.安装和配置:

sudo mkdir /etc/boa/
sudo cp ../boa.conf boa boa_indexer /etc/boa/
sudo mkdir /var/log/boa
sudo touch /var/log/boa/error_log /var/log/boa/access_log
sudo chmod -R 777 /var/log/boa/

cd /var/
sudo mkdir www
cd www/
vim index.html
sudo vim index.html

sudo /etc/boa/boa

boa.conf文件

# Boa v0.94 configuration file
# File format has not changed from 0.93
# File format has changed little from 0.92
# version changes are noted in the comments
#
# The Boa configuration file is parsed with a lex/yacc or flex/bison
# generated parser.  If it reports an error, the line number will be
# provided; it should be easy to spot.  The syntax of each of these
# rules is very simple, and they can occur in any order.  Where possible
# these directives mimic those of NCSA httpd 1.3; I saw no reason to
# introduce gratuitous differences.

# $Id: boa.conf,v 1.25 2002/03/22 04:33:09 jnelson Exp $

# The "ServerRoot" is not in this configuration file.  It can be compiled
# into the server (see defines.h) or specified on the command line with
# the -c option, for example:
#
# boa -c /usr/local/boa


# Port: The port Boa runs on.  The default port for http servers is 80.
# If it is less than 1024, the server must be started as root.

Port 8080

# Listen: the Internet address to bind(2) to.  If you leave it out,
# it takes the behavior before 0.93.17.2, which is to bind to all
# addresses (INADDR_ANY).  You only get one "Listen" directive,
# if you want service on multiple IP addresses, you have three choices:
#    1. Run boa without a "Listen" directive
#       a. All addresses are treated the same; makes sense if the addresses
#          are localhost, ppp, and eth0.
#       b. Use the VirtualHost directive below to point requests to different
#          files.  Should be good for a very large number of addresses (web
#          hosting clients).
#    2. Run one copy of boa per IP address, each has its own configuration
#       with a "Listen" directive.  No big deal up to a few tens of addresses.
#       Nice separation between clients.
# The name you provide gets run through inet_aton(3), so you have to use dotted
# quad notation.  This configuration is too important to trust some DNS.

#Listen 192.68.0.5

#  User: The name or UID the server should run as.
# Group: The group name or GID the server should run as.

#User nobody
#Group nogroup
User 0
Group 0

# ServerAdmin: The email address where server problems should be sent.
# Note: this is not currently used, except as an environment variable
# for CGIs.

#ServerAdmin root@localhost

# ErrorLog: The location of the error log file. If this does not start
# with /, it is considered relative to the server root.
# Set to /dev/null if you don't want errors logged.
# If unset, defaults to /dev/stderr

ErrorLog /var/log/boa/error_log
# Please NOTE: Sending the logs to a pipe ('|'), as shown below,
#  is somewhat experimental and might fail under heavy load.
# "Usual libc implementations of printf will stall the whole
#  process if the receiving end of a pipe stops reading."
#ErrorLog "|/usr/sbin/cronolog --symlink=/var/log/boa/error_log /var/log/boa/error-%Y%m%d.log"

# AccessLog: The location of the access log file. If this does not
# start with /, it is considered relative to the server root.
# Comment out or set to /dev/null (less effective) to disable
# Access logging.

AccessLog /var/log/boa/access_log
# Please NOTE: Sending the logs to a pipe ('|'), as shown below,
#  is somewhat experimental and might fail under heavy load.
# "Usual libc implementations of printf will stall the whole
#  process if the receiving end of a pipe stops reading."
#AccessLog  "|/usr/sbin/cronolog --symlink=/var/log/boa/access_log /var/log/boa/access-%Y%m%d.log"

# UseLocaltime: Logical switch.  Uncomment to use localtime
# instead of UTC time
#UseLocaltime

# VerboseCGILogs: this is just a logical switch.
#  It simply notes the start and stop times of cgis in the error log
# Comment out to disable.

#VerboseCGILogs

# ServerName: the name of this server that should be sent back to
# clients if different than that returned by gethostname + gethostbyname

#ServerName www.your.org.here

# VirtualHost: a logical switch.
# Comment out to disable.
# Given DocumentRoot /var/www, requests on interface 'A' or IP 'IP-A'
# become /var/www/IP-A.
# Example: http://localhost/ becomes /var/www/127.0.0.1
#
# Not used until version 0.93.17.2.  This "feature" also breaks commonlog
# output rules, it prepends the interface number to each access_log line.
# You are expected to fix that problem with a postprocessing script.

#VirtualHost

# DocumentRoot: The root directory of the HTML documents.
# Comment out to disable server non user files.

DocumentRoot /var/www

# UserDir: The name of the directory which is appended onto a user's home
# directory if a ~user request is recieved.

UserDir public_html

# DirectoryIndex: Name of the file to use as a pre-written HTML
# directory index.  Please MAKE AND USE THESE FILES.  On the
# fly creation of directory indexes can be _slow_.
# Comment out to always use DirectoryMaker

DirectoryIndex index.html

# DirectoryMaker: Name of program used to create a directory listing.
# Comment out to disable directory listings.  If both this and
# DirectoryIndex are commented out, accessing a directory will give
# an error (though accessing files in the directory are still ok).

DirectoryMaker /usr/lib/boa/boa_indexer

# DirectoryCache: If DirectoryIndex doesn't exist, and DirectoryMaker
# has been commented out, the the on-the-fly indexing of Boa can be used
# to generate indexes of directories. Be warned that the output is
# extremely minimal and can cause delays when slow disks are used.
# Note: The DirectoryCache must be writable by the same user/group that
# Boa runs as.

# DirectoryCache /var/spool/boa/dircache

# KeepAliveMax: Number of KeepAlive requests to allow per connection
# Comment out, or set to 0 to disable keepalive processing

KeepAliveMax 1000

# KeepAliveTimeout: seconds to wait before keepalive connection times out

KeepAliveTimeout 10

# MimeTypes: This is the file that is used to generate mime type pairs
# and Content-Type fields for boa.
# Set to /dev/null if you do not want to load a mime types file.
# Do *not* comment out (better use AddType!)

MimeTypes /etc/mime.types

# DefaultType: MIME type used if the file extension is unknown, or there
# is no file extension.

DefaultType text/plain

# CGIPath: The value of the $PATH environment variable given to CGI progs.

CGIPath /bin:/usr/bin:/usr/local/bin

# SinglePostLimit: The maximum allowable number of bytes in
# a single POST.  Default is normally 1MB.

# AddType: adds types without editing mime.types
# Example: AddType type extension [extension ...]

# Uncomment the next line if you want .cgi files to execute from anywhere
#AddType application/x-httpd-cgi cgi

# Redirect, Alias, and ScriptAlias all have the same semantics -- they
# match the beginning of a request and take appropriate action.  Use
# Redirect for other servers, Alias for the same server, and ScriptAlias
# to enable directories for script execution.

# Redirect allows you to tell clients about documents which used to exist in
# your server's namespace, but do not anymore. This allows you to tell the
# clients where to look for the relocated document.
# Example: Redirect /bar http://elsewhere/feh/bar

# Aliases: Aliases one path to another.
# Example: Alias /path1/bar /path2/foo

Alias /doc /usr/doc

# ScriptAlias: Maps a virtual path to a directory for serving scripts
# Example: ScriptAlias /htbin/ /www/htbin/

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

 

5.参考:

1.Ubuntu16.04安装BOA服务器

2.BOA服务器与CGI

3.移植boa服务器

4.嵌入式Linux:ARM开发板移植Boa搭建Web服务器

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

 类似资料: