For a small Web server boa in Linux, 0 is used)

Source: Internet
Author: User
Tags small web server

OA is a small web server that can be used on multiple platforms and is common in embedded systems.

BOA's official website is www.boa.org, where you can download the latest version of BOA: boa-0.94.13.tar.gz (but this "latest" is something N years ago ).

The following is the installation and testing process in the fedora system. In the future, the fedora system will not be repeatedly emphasized, and Linux and Fedora will not be distinguished.

1. Extract
$ Tar zxvf boa-0.94.13.tar.gz
2. Go to the BOA source code directory.
$ Cd boa-0.94.13/src
3. Configuration
$./Configure
4. Compile
$ Make

Note: An error is reported during compilation. The error message is as follows:

Util. C: 100: 1: Error: "T" and "->" cannot provide a valid preprocessing identifier.
Make: *** [util. O] Error 1 (Chinese Version)
Util. C: 100: 1: Error: pasting "T" and "->" does not give a valid preprocessing token
Make: *** [util. O] Error 1 (English version)

The modification method is as follows:
In this directory, copy the file compat. H (BOA-0.94.13/src/compat. h)

# Define timezone_offset (FOO) Foo #-> tm_gmtoff

Change

# Define timezone_offset (FOO) foo-> tm_gmtoff

Remove "#".
5. Re-compile and pass. After successful execution, an executable file boa will be generated in the current directory (src directory, we can copy it to the/usr/bin or/usr/local/bin directory (of course, it can also be another path). According to my habits, put it in the/usr/local/bin directory.
6. Configure Boa
We need to modify the boa configuration file boa. conf and place it in a specific directory. Copy the BoA. conf file under the BOA-0.94.13 directory to the/etc/BOA directory (the boa directory needs to be created by ourselves. Why? Let's take a look at the./src/defines. H source code. A macro in it defines the root directory of the server, as shown below:

/***** Change this, or use-C on the command line to specify it *****/
# Ifndef server_root
# Define server_root "/etc/boa"
# Endif

It also prompts that we can use-C to specify this root directory when running the command. However, we use the default method.
In addition, you must make the following changes:

Group nogroupChangeGroup 0
ScriptAlias/cgi-bin // usr/lib/cgi-bin/ChangeScriptAlias/cgi-bin // var/www/cgi-bin/

Because the system does not have a nogroup group by default (0 indicates the root group, you can use the id command to view it, see below), but there is a nobody user, so you do not need to modify the user item. ScriptAlias specifies the CGI program directory. Here we set it to/var/www/cgi-bin, which means that various CGI programs will be placed in this directory in the future.
The following is a description of the configurations found on the Internet. It is actually a Chinese translation of BOA. conf.

Port: the port that the boa server listens to. The default port is 80. If the port is less than 1024, the root user must start the server.
Listen: the bound IP address. If this parameter is not used, all addresses are bound.
User: the identity of the client connected to the server, which can be the user name or uid.
Group: the group of clients connected to the server. It can be the group name or GID.
Serveradmin: the email address to be notified when the server fails.
Errorlog: Specifies the error log file. If the path does not start with "/", it is relative to the serverroot path. If no configuration is available, the file is/dev/stderr. If you do not want to record logs, specify the file as/dev/null.
Accesslog: Set the access log file, similar to errorlog.
Uselocaltime: sets the local time. This parameter is commented out when UTC is used. This parameter has no value.
Verbosecgilogs: records the start and stop times of CGI in the error log file. If no log is recorded, comment this parameter. This parameter has no value.
Servername: Specifies the server name. If the client uses gethostname + gethostbyname, it is returned to the client.
Virtualhost: virtual host switch. If you use this parameter
Add an IP address to the directory as the new DocumentRoot.
Process client requests. For example, if DocumentRoot is set to/var/WWW, http: // localhost/is converted to/var/www/127.0.0.1/. If you comment on this parameter,/var/www/is used /.
DocumentRoot: root directory of the HTML file (that is, the website directory ).
Userdir: Specifies the user directory.
Directoryindex: Specifies the file for pre-generated directory information. Note that this variable uses the directorymaker variable. This variable is used to set the default homepage file name.
Directorymaker: Specifies the program used to generate a directory. Commenting on this variable will not allow column directories.
Directorycache: When the directoryindex file does not exist and direcotrymaker is commented out, the specified directory of this parameter is listed on the client.
Keepalivemax: Number of requests allowed by each connection. If you set this value to "0", the number of requests is not limited.
Keepalivetimeout: the number of seconds to wait for the next request before closing the persistent connection. (Seconds ).
Mimetypes: sets the file containing mimetypes information, which is generally/etc/mime. types.
Defaulttype: the default mimetype type, usually text/html.
Cgipath: equivalent to the $ PATH variable used for CGI programs.
Singlepostlimit: Maximum number of bytes allowed for one post. The default value is 1 MB.
Addtype: Add a type not specified by mimetype, for example, addtype Type Extension [extension...]. To use CGI, you must add the CGI type: addtype application/X-httpd-CGI.
Redirect: Redirection file.
Aliases: Specifies the path alias.
ScriptAlias: Specifies the virtual path of the script path.

Before starting BOA, make sure that other Web servers in Linux are disabled. For example, httpd. -- In the test, httpd is not enabled for Linux. All right, now you can start boa and enter BOA in the command line. Of course, we have copied BOA to the/usr/local/bin directory.
After boa is started, you can enter the Linux IP address in the browser (you can view it using the ifconfig command ). In this case, the start page of the Fedora Project is displayed in the browser (you can check the index.html in the/var/wwwdirectory ).
(Note: In actual tests, BOA cannot be started when a common user is used, and the root user is required. The reason is unknown .)

# ID
Uid = 0 (Root) gid = 0 (Root) groups = 0 (Root), 1 (BIN), 2 (Daemon), 3 (sys), 4 (ADM ), 6 (Disk), 10 (wheel)
# Ps aux | grep Boa
Nobody 2927 0.0 0.1 1924 pts/1 s Boa
Root 2931 0.0 0.1 5504 688 pts/1 S + grep Boa

In the test, we put the HTML webpage into the/var/www/html directory, and put the CGI program under the/var/www/cgi-bin directory. In this case, if you want to upload a website (hello.html), you can enter http: // 192.168.184.100/html/hello.html in the browser. The IP address here is the IP address of Linux.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.