Porting embedded web server boa (2)

Source: Internet
Author: User
Porting embedded web server boa (2)

Author: Li qianguang, Zheng Zhe

This article is excerpted from the relevant chapter in the author "embedded Linux system development details-Based on ep93xx series arm.

The third step is to test whether BOA can work normally, whether static html pages can be accessed normally, and whether CGI scripts can run normally. Generally, NFS is used for testing, you can copy the/etc directory on the Embedded Target System to the NFS shared directory of the host, and then mount the etc directory under the NFS shared directory to the/etc directory on the target system again. In this way, various configuration files under the etc directory can be modified on the host and saved to the target system.

Assume that the host/NFS directory is a shared directory, and create a WWW sub-directory under it as the main directory of the web site. Its content is as follows:

# Ls

Cgi-bin images index.html

Index.html is the homepage for testing, images is the subdirectory for storing various images, and cgi-bin is the directory for storing CGI scripts. Boa. CONF configuration. Currently, the main directory of the HTML document is/var/WWW, And the CGI script directory is/var/www/cgi-bin, run the following command to mount the/nfs/WWW directory of the host to the/var/WWW directory on the target board. Then you can run BOA:
# Mount-t nfs 192.168.67.1:/nfs/www/var/www-O nolock
# Boa
Run the browser on the workstation to perform the test. In the address bar, enter the target system IP address, namely http: // 192.168.67.16. The relevant page is displayed, indicating that the static html page passes the test.

Next we will test the CGI script. We need a CGI script for testing. You can write the simplest Hello WorldProgram, ExampleCodeAs follows:

# Include <stdio. h>
Void main (){
Printf ("Content-Type: text/html/n ");
Printf ("<HTML>/N ");
Printf ("Printf ("<body>/N ");
Printf ("Printf ("</body>/N ");
Printf ("Exit (0 );
}
Then perform cross-compilation to copy the obtained helloworld. cgi to the/nfs/www/cgi-bin directory of the host.
# Arm-Linux-gcc-O helloworld. cgi helloworld. c
# Cp helloworld. cgi/nfs/www/cgi-bin
Enter http: // 192.168.67.16/cgi-bin/helloworld. cgi in the address bar of the browser. The relevant page is displayed, indicating that the CGI script has passed the test.

Now we can let BOA work properly on the Embedded Target System, and the embedded web server is successfully transplanted.

In the above porting process, it is best to set the Error Log File errorlog in Boa. conf to allow BOA to record error information;
When testing static html pages and CGI scripts, it is best to view the Error Log File regardless of the result;
CGI script tests are prone to errors with insufficient permissions. Ensure that the main directory, CGI script directory, and temporary file directory accessed by BOA (if the TMP environment variable is not set, the default value is the/tmp directory. the user in conf indicates.

The content in the next section is web-based application development. Stay tuned!

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.