Port The Boa web server on the PC

Source: Internet
Author: User
Tags small web server

Boa is a very small Web server with only about 60 kb of executable code. It is a single-task web server that can only complete user requests in sequence, rather than fork new processes to process concurrent connection requests. However, BOA supports CGI and can execute a process for the CGI program fork. Next we will explain how BOA can be transplanted and modified on a PC (in the Virtual Machine redhatas5 environment.

BOA: http://www.rayfile.com/zh-cn/files/d7a7b368-c236-11e0-a55a-0015c55db73d/

1. Configure and compile Boa

1. # tar zxvf boa-0.94.13.tar.gz

2. # mv BOA-0.94.13 boa_pc

3. # cd boa_pc/src

4. Effective directory settings for BOA. conf

A configuration file boa. conf needs to be read during BOA startup. Its path is determined by the following file:

Row 30th # define server_root "/etc/boa", default:/etc/BOA folder

For the sake of unified path, we changed to: "/home/boa". Next, all files related to boa will be stored under/home/boa.

5. Modify src/boa. c

 Comment out the following statement:

If (setuid (0 )! =-1)

{

Die ("icky Linux kernel bug !");

}

To:

# If 0

If (setuid (0 )! =-1)

{

Die ("icky Linux kernel bug !");

}

# Endif

Otherwise, a message is displayed when you run boa.

BOA. C: 226-Icky Linux kernel bug! : No suchfile or directory Error

6. #./configure

7. Make

Generate an executable BOA program in the current directory, and run./boa. The PS shows that BOA is working properly.

Note: Some compilers will prompt the following errors and follow the corresponding methods to solve them.

Util. C: 100: 1: pasting "T" and "->" does not give a valid preprocessing token make: [util. O] error1

Solution:

Method>. Modify

# Define timezone_offset (FOO) Foo #-> tm_gmtoff

Is:

# Define timezone_offset (FOO) foo-> tm_gmtoff

 

2. modify the configuration file boa. conf.

1. Create the/home/BOA directory, copy boa. conf to the/home/BOA directory, and perform the following steps.

# Mkdir/home/Boa

# Cp boa. CONF/home/Boa

2. Access Port Number settings

About 25: port 80. You can set the default port number when accessing the webpage to 80.

If the port number is changed to 8080, access must be performed in the following format: http: // 192.168.1.3: 8080

This method is generally used when multiple BOA servers are running on the same computer.

Keep the default value here.

3. Modify the access permission:

Change User nobody to user 0

Change Group nogroup to group 0

4. Set the log directory: the boa log contains two parts: errorlog and accesslog.

The default values are/var/log/BOA/error_log and/var/log/BOA/access_log.

Therefore, we should change it:

Errorlog/home/BOA/error_log

Accesslog/home/BOA/access_log

(Note: The/home/BOA directory must be writable. Otherwise, an error occurs: log. C: 73-unable to dup2 the Error Log: Bad file R .)

5. Set the HTML file directory:

The default value is DocumentRoot/var/www.

We changed it:

DocumentRoot/home/BOA/WWW

6. Set the default homepage: directoryindex index.html

This is the name of the webpage to be accessed without being specified. The webpage returned by the server by default is not modified.

7. Set the CGI script directory: Set

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

Change

ScriptAlias/cgi-bin // home/BOA/cgi-bin

Note: Boa provides CGI programming interfaces to enable interaction between webpages. We will explain them later.

8. Test

In/home/BOA/www, you can test the web page (including the index.html file)

Here we will create a file named index.html, and write a: Hello Boa...

Enter http: // 192.168.1.101/in IE to view helloo boa.

This proves that the entire boa is successfully built.

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.