Online Book Reader

Home Category

UNIX System Administration Handbook - Evi Nemeth [407]

By Root 2900 0
server is simply a system that’s configured to answer HTTP requests. To convert your generic UNIX system into a web hosting platform, you need to install a daemon that listens for connections on TCP port 80 (the HTTP standard), accepts requests for documents, and transmits them to the requesting user.

Web browsers such as Netscape and Internet Explorer contact remote web servers and make requests on behalf of users. The documents thus obtained can contain hypertext pointers (links) to other documents, which may or may not live on the server that the user originally contacted. Since the HTTP protocol standard is well defined, clients running on any operating system or architecture can connect to any HTTP server. This platform independence, along with HTTP’s ability to transparently pass a user from one server to another, have helped to spark its amazing success.

There is life beyond straight HTTP, however. Many enhanced protocols have now been defined for providing everything from encryption to streaming video. These additional services are often managed by separate daemons, even if they are provided by the same physical server. For example, one of the most popular enhanced services is Secure HTTP, aka HTTPS. It’s handled by a daemon that understands the Secure Socket Layer (SSL) protocol and listens for requests on TCP port 443. You may need to obtain additional daemons from a third-party supplier if your UNIX vendor does not provide everything you need as part of the base operating system.

Uniform resource locators


A uniform resource locator (URL) is a pointer to an object or service on the Internet. It describes how to access an object by means of five basic components:

• Protocol or application

• Hostname

• TCP/IP port (optional)

• Directory (optional)

• Filename (case sensitive; often ends in “.htm” or “.html”)

Exhibit A illustrates a typical URL and its components.

Exhibit A Parts of a URL

Table 22.1 shows the protocols that are commonly used in URLs.

Table 22.1 URL protocols

How HTTP works


HTTP is the protocol that makes the World Wide Web really work, and to the amazement of many, it is an extremely basic, stateless, client/server protocol. In the HTTP paradigm, the initiator of a connection is always the client (usually a browser). The client asks the server for the “contents” of a specific URL. The server responds with either a spurt of data or with some type of error message. In HTTP versions 0.9 and 1.0, the connection is then closed; in HTTP 1.1, the client can go on to request another object.

Because HTTP is so simple, you can easily make yourself into a crude web browser by using telnet. Since the standard port for HTTP service is port 80, just telnet directly to that port on your web server of choice. Once you’re connected, you can issue HTTP commands. The most common command is GET, which requests the contents of a document. Usually, GET / is what you want, since it requests the root document (usually, the home page) of whatever server you’ve connected to. HTTP is case sensitive, so make sure you type commands in capital letters.

% telnet localhost 80

Trying 127.0.0.1...

Connected to localhost.xor.com.

Escape character is '^]'.

GET /

Connection closed by foreign host.

CGI scripting: generating content on the fly


In addition to serving up static documents, an HTTP server can provide the user with content that has been created on the fly. For example, if you wanted to provide the current time and temperature to users visiting your web site, you might have the HTTP server execute a script to obtain this information. This amaze-the-natives trick is normally accomplished with the Common Gateway Interface, or CGI.

CGI is not a programming language, but rather a specification that allows an HTTP server to exchange information with other programs. Most often, CGI scripts are Perl or C programs that have been written specifically to interface with an HTTP server. But really, almost any programming language that

Return Main Page Previous Page Next Page

®Online Book Reader