About embedded Web servers

Source: Internet
Author: User
Tags closing tag html form small web server web database

Configuration file for 1.boa boa.conf

  

Port 80//service access ports

User 0
Group 0

Errorlog/var/log/boa/error_log//error log Address
Accesslog/var/log/boa/access_log//Access log file

Documentroot/var/www//html Document's home directory

Userdir public_html//

DirectoryIndex index.html//default Access file

Directorymaker/usr/lib/boa/boa_indexer

Keepalivemax 1000//Maximum number of HTTP persistent requests allowed by a connection

KeepAliveTimeout//http the number of times, in seconds, that the server waits between two requests in a persistent role

Mimetypes/etc/mime.types//Indicate mime.types file location

DefaultType text/plain//file extension not known or unknown, the default MIME type used

Cgipath/bin:/usr/bin:/usr/local/bin//provide the PATH environment variable value of the CGI program

Alias/doc/usr/doc//Add alias to Path

scriptalias/cgi-bin//var/www/cgi-bin///input site and CGI script location

2.boa Introduction

  

BOA
========================
The server is a small and efficient Web server, which is a CGI-capable, single-task HTTP server for embedded systems running under UNIX or Linux, with open source code and high performance.

is a very small Web server, its executable code only about 60KB. As a single-task Web server, Boa can only complete the user's request in turn without fork out a new process to process the concurrent connection request. But Boa supports CGI, which is able to fork out a process for CGI programs to execute. Boa's design goals are speed and safety.


Cgi
========================
Is physically a program that runs on the server and provides an interface to the client's HTML page. That is, the interface between the client and the server.

such as message book Workflow: first by the user input some information in the client, such as the name of things. Then the user click on the "message" (so far at the client), the browser transmits this information to the server's CGI directory in a specific CGI program, so the CGI program on the server according to a predetermined method to process. In this case, the information submitted by the user is stored in the specified file. The CGI program then sends a message to the client indicating that the requested task has ended. At this point the user will see the word "End of message" in the browser. The whole process is over.

3.CGI Introduction


Introduction to CGI:
=====================
First, the concept: Public Gateway Interface CGI (Common gatewayinterface) is one of the most important technologies in WWW technology, which has irreplaceable important position. CGI is an interface standard between an external application (CGI program) and a Web server, and is a discipline for passing information between CGI programs and Web servers. The CGI specification allows the Web server to execute external programs and send their output to a Web browser, CGI turning a simple set of static hypermedia documents from the Web into a complete new interactive media.

In physics, CGI is a program that runs on the server and provides an interface to the client's HTML page. That's probably not a good idea.

So let's look at a practical example:
====================================
Most of today's personal pages have a message book. The work of the message book is this: the user first input some information, such as the name of things. Then the user click on the "message" (so far at the client), the browser transmits this information to the server's CGI directory in a specific CGI program, so the CGI program on the server according to a predetermined method to process. In this case, the information submitted by the user is stored in the specified file. The CGI program then sends a message to the client indicating that the requested task has ended. At this point the user will see the word "End of message" in the browser. The whole process is over.


Second, function: The vast majority of CGI programs are used to interpret the input information from the form, and the server to produce the corresponding processing, or the corresponding feedback to the browser. CGI programs make Web pages interactive.

There are several main uses of CGI applications:

1. Send a customized reply based on the HTML form that the browser fills in;

2. Create a click-to-zoom image reduction chart;

3. Create a database where visitors can search for content;

4. Provide the server and database interface, and convert the results into HTML documents;

5. Create a Dynamic HTML text block.

Third, the processing steps:

⑴ send user requests to the server over the Internet.
  
The ⑵ server receives the user request and gives it to the CGI program for processing.
 
The ⑶CGI program transmits the processing results to the server.
 
The ⑷ server sends the results back to the user.

Four, advantages:
CGI can provide us with many features that HTML cannot do. such as a. a register B. Submission of customer information forms and Statistics C. Search program D.web database, HTML is no way to remember the customer any information.

The use of HTML is also unable to record information into a particular file. To record the client's information on the server's hard disk, use CGI. This is the most important role of CGI, which complements the lack of HTML.

Make it possible to run an outside part of an application (or gateway) under a network server. The Cgi-bin directory is where CGI scripts are stored. These scripts enable the WWW server and browser to run external programs without having to start another cause.

It is a program that runs on a Web server and is triggered by input from the browser. CGI is an interface that runs an external program (or Gateway) under an HTTP server that allows network users to access a type of application on a remote system, as if they
The same as those remote computers that are actually used.

CGI allows the browser to interact with the server, and if you have ever encountered a fill-in or search on the web, there is a good chance that CGI will be used.


V. How the Application works:
1. The browser uses an HTML form or hyperlink request to refer to the URL of the previous CGI application.

2. The server receives the request.

3. The server executes the specified CGI application.

4.CGI applications perform the actions required, usually based on what the browser has entered.

5.CGI applications format the results as Web servers and browsers can understand documents (usually HTML pages).

6. The Web server returns the results to the browser.


Vi. issues of attention
The CGI application runs on the server system that the browser can request, and the server CPU time and memory are required for execution. If there are tens of thousands of such programs running at the same time, that would put a high demand on the server system. You should consider this problem carefully to prevent the server system from crashing.

An imperfect CGI application can become a channel for someone else to enter a server system illegally, potentially causing important data to be deleted or leaked.

4.XML Introduction

First, the concept:
==================
XML (extensible Markup Language), an extensible identity language. "Extensibility" identifies "language". Each word clearly clarifies the importance of XML.
Features and functions. Let's analyze it carefully:


1. Extensibility---Using XML, you can create your own tags for your documents.
=================
The first word of XML is "extensibility," which is why XML is powerful and resilient.
In HTML, there are many fixed tags that we must remember and then use, and you cannot use tags that are not in the HTML specification. And in XML, you can build
Any tags you need. You can make the most of your imagination and give your document some good-to-remember tag names. For example, your document contains some games
, you can create a tag named <game>, and then set up <RPG>,<SLG> and other tags under <game> under the game category. As long as it is clear and easy
Understand that you can build any number of tags.


2. Identify---Use XML you can identify the elements in the document.
=================
The second word of XML is "identity", which indicates that the purpose of XML is to identify the elements in the document.

Whether you are HTML or XML, the essence of identity is easy to understand, if not identified, your document appears to the computer as a very long string, each
Words look the same, there is no point of emphasis. With logos, your documents are easy to read and understand, and you can divide paragraphs and list headings. XML, you are more
You can use its extensibility to establish a more appropriate identity for your document.

<b>frist step<b>
Here <b> represents bold, only to indicate that the "frist step" character is displayed in bold,,<b> itself does not contain any actual information, on the page you do not see
To <b>, the real message is "frist step".


3. Language---Use XML you need to follow a specific syntax to identify your document.
=================
The third word of XML is "language". This shows that XML as a language must follow certain rules. Although the extensibility of XML allows you to create a new identity, it still
Specific structures, grammars, and explicit definitions must be followed.

In the computer field, languages are often used to program functions and applications, but not all "languages" are programmed, and XML is just a way to define
The language that identifies and describes the information.

Two. XML structured---XML encourages the document to be structured, and all information is arranged in a certain relationship.
====================
"Structured" sounds too abstract, so we understand that structuring is creating a framework for your documents, like writing an outline first. Structured to make
Your documents don't look cluttered, and each part is closely linked to form a whole.

There are two principles of structuring:
1. Each part (each element) is associated with other elements. The associated progression forms the structure.
2. The meaning of the logo itself is separate from the information it describes.

Let's look at a simple example to help understand:
<?xml version= "1.0" encoding= "GB2312"?>
<myfile>
<title>xml Easy Learning Manual </title>
<chapter>xml Quick Start
<para> What is xml</para>
<para> benefits of using XML </para>
</chapter>
The concept of <chapter>xml
<para> Scalability </para>
<para> logo </para>
</chapter>
</myfile>
This is the XML description document for this article, and you can see that the identity is three-level related and very clear:
<myfile>
<chapter>
<para>
...
</para>
</chapter>
</myfile>
The above document structure, which we call the "document Tree", is the parent element, such as <MYFILE>, where branches and pages are child elements, such as <chapter> and <para>.


Third, the benefits of XML
==================
What are the benefits of using XML? See the description of the organization (XML standard creator):

XML makes the use of SGML on the web more "simple and straightforward": simplifying the process of defining file types, simplifying the process of programming and processing SGML files,
simplifies the delivery and sharing on the web.

1.XML can be widely used anywhere in the web;
2.XML can meet the needs of network applications;
3. Using XML will make programming easier;
4.XML easy to learn and create;
5.XML code will be clear and easy to read and understand;

Iv. XML Instance Analysis
==================
XML is very simple and easy to learn. If you are familiar with HTML, you will find its document and HTML very similar to the same sample document (Example 1):

? xml version= "1.0"?><br><br>
<myfile><br><br>
<title>xml Quick start</title><br><br>
<author>ajie</author><br><br>
<email>[email protected]</email><br><br>
<date>20010115</date><br><br>
</myfile>

The first line is an XML declaration that indicates that the document follows the specification for version 1.0 of XML.

The second line defines the first element in the document, also known as the root element: < myfile>. This is similar to the < html> opening tag in HTML.
Note that this name is freely defined by itself.

The following defines four sub-elements: Title,author,email, and date. Describe the title, author, mailbox and date of the article separately. Of course, you can use
Chinese to define these tags and look more understandable:

<?xml version= "1.0" encoding= "GB2312"?>
< articles >
< title >xml Easy study manual </title >
< author >ajie</>
< mailbox >[email protected]</box >
< date >20010115</date >
</articles >


This is the XML document, any user who master HTML can directly write such a simple XML document.


In addition, learning XML must also master a page scripting language, Common is JavaScript and VB script. Because XML data is using script
Implements the invocation and interaction in HTML. Let's look at one of the simplest examples (example 2):

1. Save the following code as myfile.html

<script language= "Javascript" for= "window" event= "onload" >
var xmldoc = new ActiveXObject ("Microsoft.XMLDOM");
Xmldoc.async= "false";
Xmldoc.load ("Myfile.xml");
nodes = XmlDoc.documentElement.childNodes;
Title.innertext = Nodesitem (0). text;
Author.innertext = Nodes.item (1). text;
Email.innertext = Nodes.item (2). text;
Date.innertext = Nodes.item (3). text;

</script>
<title> calling XML data in HTML </title>
<body bgcolor= "#FFFFFF" >
<b> Title: </b>
<span id= "title" > </span>
<b> Author: </b>
<span id= "Author" ></span>
<b> mailbox: </b>
<span id= "Email" ></span>
<b> Date:</b>
<span id= "Date" ></span>
</body><br><br>

2. Save the following code as Myfile.xml

<?xml version= "1.0" encoding= "GB2312"?>
<myfile>
<title>xml Easy Learning Manual </title>
<author>ajie</author>
<email>[email protected]</email>
<date>20010115</date>
</myfile>

3. Place them in the same directory, open with IE5 or above browser, and you can see the effect. Learn and master a script that you will truly understand
XML is an incredibly powerful feature.

Five. The difference between XML and HTML
==========================
Both XML and HTML come from SGML, and they all contain tags, with similar syntax, and the biggest difference between HTML and XML is that HTML is a stereotyped markup language,
It is described by an intrinsic tag, displaying the content of the Web page. For example, < h1> represents the first row header with a fixed size. In contrast, XML does not have a fixed tag,
XML cannot describe the specific appearance and content of a Web page, it simply describes the data form and structure of the content.

This is a qualitative difference: The Web page mixes the data with the display, while the XML separates the data from the display.

We look at the above example, in the myfile.htm, we only care about the way the page is displayed, we can design different interface, in different ways to compose the page
The data is stored in the Myfile.xml, and no change is required.

(If you're a programmer, you'll be surprised to find that this is very similar to the idea of modular object-oriented programming!) Actually the webpage is not a kind of procedure? )

It is this difference that makes XML convenient, efficient and extensible in Web applications and information sharing. So we believe that XML is an advanced method of data processing,
will make the network leap into a new realm.


Six. Strict format of XML
=======================
Drawing on the lessons of the HTML loose format, XML insisted on a "good format" at the outset.

Let's look at some of the HTML statements, which are ubiquitous in HTML:

1.
Sample
2.< b>< i>sample</b></i>
3.< td>sample</td>
4.< Font color=red>samplar</font>

In the XML document, the syntax of the preceding statements is incorrect. Because:

1. All marks must have a corresponding closing tag;
2. All XML tags must be properly nested;
3. All XML tags are case-sensitive;
4. The attributes of all tokens must be enclosed in "";
So the above statement is correctly spelled in XML

1.
Sample
2.< b>< i>sample</i></b>
3.< td>sample</td>
4.< font color= "Red" >samplar</font>

In addition, XML tags must follow the following naming conventions:

1. The name may contain letters, numbers and other letters;
2. The name cannot begin with a number or "_" (underscore);
3. The name cannot begin with the letter XML (or XML or xml:).
4. The name cannot contain spaces.

Any errors in the XML document will get the same result: The page cannot be displayed. Browser developers have reached an agreement to implement strict and
Critical parsing, any small error will be reported. You can modify the above myfile.xml, for example, change < email> to < Email>
Open Myfile.xml directly with IE5 and you will get an error message page:

<?xml version= "1.0" encoding= "GB2312"?>
<myfile>
<title>xml Easy Learning Manual </title>
<author>ajie</author>
<email>[email protected]</email>
<date>20010115</date>
</myfile>

About embedded Web servers

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.