Because of the ability to provide graphics, audio and other multimedia data, WWW has become Internet users favorite way of access, most of the current Internet traffic is generated from WWW browsing. Thanks to this kind of multimedia browsing, the Internet is no longer just used by professionals, but ordinary users who don't know much about computers can get into the Internet and enjoy the fresh content of the Internet.
Although the WWW service is very popular, it is still a professional task to establish a WWW server to provide WWW service. There are many kinds of software currently available to provide WWW services, running on different operating systems, some of which can run on a personal Windows desktop system, have a graphical interface and are easy to configure, so many users who wish to try to provide WWW services often install and try to run these systems. However, these systems are essentially systems that can only provide extremely limited service capabilities, and should at least use Windows NT systems if they are to provide a server system that allows normal Internet access. When a higher performance and stability system is required, UNIX should be selected. FreeBSD is clearly a very good WWW server operating system to choose from when using Intel platform systems.
Basic concepts
Although ordinary users only need to understand some common sense concepts, such as URLs, HTML, and so on, they can easily access web resources on the Internet through the browser. However, to build a Web server, you need more relevant concepts, such as HTTP, MIME, CGI, and so on to understand the settings of the Web server parameters, to correctly set these parameters to establish a truly available server system.
Hypertext Transfer Protocol HTTP
The network protocol used to support WWW browsing is HTTP, which is one of the most basic client/server access protocols. The browser sends the request to the server, and the server responds to the corresponding Web page. The HTTP protocol, which began in 1990 and has developed to the current HTTP 1.1 standard, has a considerable amount of expansion, but its most basic implementation is very simple, and the server needs to perform a relatively small amount of extra processing, which is one of the reasons why Web server software is so numerous.
Request method
Typically, the HTTP protocol uses port 80来 to provide client access, so you can also use other network software, such as Telnet, to simulate a client sending a request to the server to see how HTTP is transmitted.
$ telnet webserver
trying 192.168.0.1
... Connected to webserver.
Escape character is ' ^] '.
Get/index.html
When Telnet displays information such as connect, the server waits for the user to enter the request without prompting. In the example above, the user enters the get/index.html directive, the server immediately returns the appropriate Web page, and then closes the connection.
Clients can have different types of requests sent to the server, so that the server can handle different types of requests depending on the type of request. In HTTP 1.0, the three most basic request types, get, post, and head are defined, and the request methods are implemented in the same way as in the previous example, and the client program sends the request to the server with an uppercase directive followed by the specific data.
A GET request is the most common, followed by the location of a Web page where the server accepts the request and returns its requested page. In addition to the page position as a parameter, the request can also follow the protocol version such as http/1.0 as an argument to send more information to the server.
Post requests require the server to receive a large amount of information, in addition to the parameters followed after the post, the browser will continue to send data after the server to process. Usually, the Post method is not separate from the CGI program, and the server should start a CGI program to process the data sent by post.
The head request communicates between the client program and the server without returning a specific document. When you use the Get and post methods, the server eventually returns the resulting document to the client, and the browser refreshes the display. The head request is different, it only exchanges some internal data, this data does not affect the browsing process. Therefore, the head method is usually not used alone, but is complementary to other request methods. Some search engines use the automated search robot to use this method to obtain information on the Web page, or for security authentication, use this method to pass authentication information.
In addition to these three most common access methods, more access method types are defined in HTTP 1.1, such as put, for placing pages in the correct location, delete for deleting related documents, and so on. These methods are not commonly used, so most Web server software does not implement them. However, they are useful for specific occasions, such as when using software to edit pages, which the Web editor can use to manage different Web pages.
If the server does not support a client-sent request method, the server returns an error and immediately closes the connection.