Web Servers (IIS, PWS and Apache) : WW W .D e

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Web Servers (IIS, PWS

and Apache)
21.1 Introduction
In this chapter, we discuss specialized softwarecalled a Web serverthat responds to cli- ent (e.g., Web browser) requests by
providing resources (e.g., XHTML documents). For example, when users enter a Uniform Resource Locator (URL) address, such as
www.de- itel.com, into a Web browser, they are requesting a specific document from a Web serv- er. The Web server maps
the URL to a file on the server (or to a file on the servers network) and returns the requested document to the client. During this
interaction, the Web server and the client communicate using the platform-independent HyperText Transfer Protocol (HTTP), a
protocol for transferring requests and files over the Internet (i.e., between Web servers and Web browsers).
Our Web-server discussion introduces Microsoft Internet Information Services (IIS),
Microsoft Personal Web Server (PWS) and the open source Apache Web Server. Sections
21.6, 21.7 and 21.8 discuss IIS, PWS and Apache, respectively. Figure 21.1 overviews these Web servers.
For illustration purposes, we use Internet Explorer to request various documents
XHTML, Active Server Pages (ASP), Perl, Python and PHP. We discuss the specifics of ASP (Chapter 25), Perl (Chapter 27),
Python (Chapter 28) and PHP (Chapter 29). This chapter concentrates on the steps for requesting documents from a Web server.

21.2 HTTP Request Types


The two most common HTTP request types (also known as request methods) are get and post. These request types retrieve and send
client form data to a Web server. A get request sends form content as part of the URL (e.g., www.searchsomething.com/
search?query=userquery) and retrieves the appropriate resource from the Web server. In this request, the information
following the ? (query=userquery) indicates the user-specified input. For example, if the user performs a search on
Massachusetts, the last part of the URL would be ?query=Massachusetts. A get request limits the userquery to 1024
characters. If userquery exceeds this limit, the post request is used. Also, the post request updates the contents of a Web server
(e.g., posting a new mes- sage to a forum).
An HTTP request often posts data to a server-side form handler that processes the data. For example, when a user
participates in a Web-based survey, the Web server receives the information specified in the XHTML form as part of the request.
Browsers often cache (save on a local disk) Web pages for quick reloading, to reduce the amount of data that the browser
needs to download. However, browsers typically do not cache the servers response to a post request, because the next post request
may not contain the same information. For example, several users participating in a Web-based survey may request the same Web
page. Each users response changes the overall results of the survey, thus the data on the Web server is changed.
On the other hand, Web browsers cache the servers responses to a get request. With a Web-based search engine, a get
request normally supplies the search engine with the infor- mation specified in the XHTML form. The search engine then performs
the search and returns the results as a Web page. These pages are cached in the event that the user performs the same search again.

21.3 System Architecture


A Web server is part of a multi-tier application, sometimes referred to as an n-tier applica- tion. Multi-tier applications
divide functionality into separate tiers (i.e., logical groupings of functionality). Tiers can be located on the same computer or on
separate computers. Figure 21.2 presents the basic structure of a three-tier application.
The information tier (also called the data tier or the bottom tier) maintains data for the application. This tier typically stores

data in a relational database management system (RDBMS). We discuss RDBMS in further detail in Chapter 22, Database: SQL,
MySQL, DBI and ADO. For example, a retail store may have a database for product information, such as descriptions, prices and
quantities in stock. The same database also may contain customer information, such as user names, billing addresses and credit-card
numbers.

The middle tier implements business logic and presentation logic to control interac- tions between application clients and
application data. The middle tier acts as an interme- diary between data in the information tier and the application clients. The
middle-tier controller logic processes client requests from the top tier (e.g., a request to view a product catalog) and retrieves data
from the database. The middle-tier presentation logic then pro- cesses data from the information tier and presents the content to the
client.
Business logic in the middle tier enforces business rules and ensures that data are reliable before updating the database or presenting data to a user. Business rules dictate how clients can and cannot access application
data and how applications process data.
The middle tier also implements the applications presentation logic. Web applications typically present information to
clients as XHTML documents (older applications present information as HTML). XHTML is discussed in Chapter 4, Introduction to
XHTML: Part 1 and Chapter 5, Introduction to XHTML: Part 2. Many Web applications present information to wireless clients as Wireless Markup Language (WML) documents. We discuss
WML in further detail in Chapter 23, Wireless Internet and m-Business.
The client tier, or top tier, is the applications user interface. Users interact directly with the application through the user
interface. The client interacts with the middle tier to make requests and to retrieve data from the information tier. The client then
displays the data retrieved from the middle tier to the user.

21.4 Client-Side Scripting versus Server-Side Scripting


In earlier chapters, we focused on client-side scripting with JavaScript. Client-side script- ing validates user input, accesses
the browser and enhances Web pages with ActiveX con- trols, Dynamic HTML and Java applets (i.e., client-side Java programs
that execute in a browser). Client-side validation reduces the number of requests that need to be passed to the server. Interactivity
allows users to make decisions, click buttons, play games, etc. making a Web site experience more interesting. ActiveX controls,
Dynamic HTML and Java applets enhance a Web pages functionality. Client-side scripts can access the brows- er, use features
specific to that browser and manipulate browser documents.
Client-side scripting does have limitations, such as browser dependency; the browser
or scripting host must support the scripting language. Another limitation is that client-side scripts are viewable (e.g., by using the
View menus Source command in Internet Explorer) to the client. Some Web developers do not advocate this because users
potentially can view proprietary scripting code. Sensitive information, such as passwords, should not be stored or validated on the
client.
Programmers have greater flexibility when using server-side scripts. Scripts executed on the server usually generate
custom responses for clients. For example, a client might connect to an airlines Web server and request a list of all flights from
Boston to San Antonio between September 19th and November 5th. The server queries the database, dynamically generates
XHTML content containing the flight list and sends the XHTML to the client. This technology allows clients to obtain the most
current flight information from the database by connecting to an airlines Web server.
Server-side scripting languages have a wider range of programmatic capabilities than
their client-side equivalents. For example, server-side scripts can access the servers file directory structure, whereas client-side
scripts cannot access the clients file directory.
Server-side scripts also have access to server-side software that extends server functionality. These pieces of software are called ActiveX components for Microsoft Web servers and modules for Apache Web servers.
Components and modules range from pro- gramming language support to counting the number of Web page hits. We discuss some
of these components and modules in Chapters 2533.

21.5 Accessing Web Servers


To request documents from Web servers, users must know the machine names (called host names) on which Web server
software resides. Users can request documents from local Web servers (i.e, ones residing on users machines) or remote Web
servers (i.e., ones resid- ing on different machines).
Local Web servers can be accessed in two ways: through the machine name or through
localhosta host name that references the local machine. We use localhost in this book. To determine the machine name
in Windows 98, right-click Network Neighbor- hood, and select Properties from the context menu to display the Network
dialog. In the Network dialog, click the Identification tab. The computer name displays in the Computer name: field. Click
Cancel to close the Network dialog. In Windows 2000, right click My Network Places and select Properties from the context
menu to display the Network and Dialup Connections explorer. In the explorer, click Network Iden- tification. The Full
Computer Name: field in the System Properties window dis- plays the computer name.
To request a document from a remote Web server in Windows 98, double click Net- work Neighborhood, which lists all the
machine names in the network. From this list, select the name of the machine running the remote Web server. In Windows 2000,
double click My Network Places, and double click Computers Near Me. This, too, lists all the machine names in the network.
From this list, select the name of the machine running the remote Web server.
A domain name (e.g., deitel or yahoo) and an Internet Protocol (IP) address also can request documents. A domain name
represents a group of hosts on the Internet; it combines with a host name (i.e, wwwWorld Wide Web) and a top-level domain (TLD) to form a fully qualified host name, which
provides a user-friendly way to identify a site on the Internet. In a fully qualified host name, the TLD often describes the type of
organization that owns the domain name. For example, the com TLD usually refers to a commercial business, whereas the org
TLD usually refers to a non-profit organization. In addition, each country has its own TLD, such as cn for China, et for
Ethiopia, om for Oman and us for the United States.
Each fully qualified host name is assigned a unique address called an IP address, which is much like the street address of a
house. Just as people use street addresses to locate houses or businesses in a city, computers use IP addresses to locate other
computers on the Internet. The domain name server (DNS), a computer that maintains a database of host names and their
corresponding IP addresses, translates the fully qualified host name to an IP address. The translation operation is referred to as a
DNS lookup. For example, to access the Deitel Web site, type either www.deitel.com or 207.60.134.230 into a Web
browser. The DNS translates www.deitel.com into the IP address of the Deitel Web server (i.e., 207.60.134.230). The IP
address of localhost is always 127.0.0.1.

21.6 Microsoft Internet Information Services (IIS)1


Microsoft Internet Information Services (IIS) 5.0 is an enterprise-level Web server that is included with Windows 2000. Installing
IIS on a machine allows that computer to serve documents. For instructions on how to install IIS, visit www.deitel.com.
After installation, start IIS by opening the Control Panel, double clicking the
Administrative Tools icon and double clicking the Internet Services Manager icon. This opens the Internet Services
Manager dialog (Fig. 21.3)the administration program for IIS. Place the documents that will be requested from IIS either in the
default directory (i.e., C:\Inetpub\Wwwroot) or in a virtual directory. A virtual directory is an alias for an existing directory
that resides on the local machine (e.g., C:\) or on the network.

Fig. 21.3

Internet Services Manager dialog of Internet Information Services.

1. This section applies to Windows 2000 users.

In the Internet Services Manager dialog, the left pane contains the Web servers direc- tory structure. The name of the machine
running IIS (e.g., carpenterant) is listed under Internet Information Services. Clicking the + symbol to the left of the
machine name displays Default FTP Site, Default Web Site and Default SMTP Virtual Server.
The Default FTP Site is a File Transfer Protocol (FTP) site; the Default Web Site is an HTTP site. Although FTP and
HTTP permit transferring documents between a com- puter and a Web server, FTP provides a faster and more persistent connection
between the client and the Web server than HTTP. HTTP is used most frequently to request documents from Web servers. The
Default SMTP Virtual Server allows for the creation of a Simple Mail Transfer Protocol (SMTP) server, which sends and
receives electronic mail (e-mail).
Expand the Default Web Site directory by clicking the + to the left of it. In this direc- tory we will create a virtual directory for
the HTTP Web site. The Default Web Site subdi- rectories are virtual directories. Most Web documents are placed in the Web
servers Webpub (Web publishing) directory. For this example, we create our virtual directory in the Webpub virtual directory. To
create a virtual directory within this directory, right-click Webpub, select New and then Virtual Directory. This starts the Virtual
Directory Cre- ation Wizard (Fig. 21.4), which guides users through the virtual directory creation process.
To begin, click Next in the Virtual Directory Creation Wizard welcome dialog. In
the Virtual Directory Alias dialog (Fig. 21.5), enter a name for the virtual directory and click Next. We use the name
Chapter21Test, although the virtual directory may have any name provided that the name does not conflict with an existing virtual
directory name.
In the Web Site Content Directory dialog (Fig. 21.6), enter the path for the directory containing the documents that clients will view. We created a directory named C:\Chapter21Examples that serves our
documents, although any existing directory would be appropriate. If necessary, select the Browse button to navigate to the desired
directory. Click Next.

Fig. 21.4 Virtual Directory Creation Wizard welcome dialog.

Fig. 21.5

Virtual Directory Alias dialog of Virtual Directory Creation Wizard.

Fig. 21.6

Web Site Content Directory dialog of Virtual Directory Creation Wizard.

The Access Permissions dialog (Fig. 21.7) presents the virtual directory security level choices. Choose the access level
appropriate for a Web document. The Read option allows users to read and download files located within the directory. The Run
scripts (such as ASP) option allows scripts to run in the directory. The Execute (such as ISAPI applications or CGI)
option allows applications to run in the directory. The Write option allows a Web page to accept user input (e.g., users enter their
credit-card number to order a book). The Browse option allows users to navigate from one Web document to another through
hyperlinks. By default, Read and Run scripts are enabled. Click Next.
Click Finish to complete the creation of the virtual directory and exit the Virtual
Directory Creation Wizard. The newly created virtual directory, Chapter21Test, is now located under the Webpub virtual
directory. To stop IIS, right click Default Web Site (or Default FTP Site or Default SMTP Virtual Server) and select Stop.

21.7 Microsoft Personal Web Server (PWS)2


Microsoft Personal Web Server (PWS) is a scaled-down version of IIS for a personal com- puter (PC). PWS is ideal for
educational institutions, small businesses and individuals be- cause PWS does not require the PC on which it is installed to be used
exclusively as a Web server.
To install PWS, visit www.microsoft.com/msdownload/ntoptionpack/ askwiz.asp. For instructions on
installing PWS, visit the Deitel & Associates, Inc. Web site at www.deitel.com.
After installation, start PWS by opening the Control Panel. Double click the
Administration Tools icon and double click the Personal Web Manager icon. To serve documents using PWS, place the
files that will be requested in the default directory (i.e., C:\Inetpub\Wwwroot) or in a virtual directory. A virtual directory is an
alias for an existing directory that resides on the local machine (e.g., C:\) or on the network. Figure 21.8 shows the Personal
Web Manager dialog.

Fig. 21.7

Access Permissions dialog of Virtual Directory Creation Wizard.

2. This section applies to Windows 95/98/Me users.

Fig. 21.8

Personal Web Manager dialog.

On the Main screen, double click the Advanced icon at the bottom of the left pane. In the screen that appears, click the Add
button. In the Directory field of the Edit Direc- tory dialog (Fig. 21.9), enter the directory path that contains the documents
available to cli- ents. We created a directory named C:\Chapter21Examples to serve our documents. You may choose any
existing directory. If necessary, select the Browse button to navigate to the directory. In the Alias field, provide the virtual
directory name (e.g., Chapter21Test). Next, select the security level of the virtual directory. The Read option allows users to
read and download files residing in the virtual directory. The Exe- cute option allows an application to run in the directory. The
Scripts option allows scripts to run in the directory. By default, Read and Scripts are enabled. When finished, click OK to
create the directory. To stop PWS, select the Stop button from the Personal Web Manager dialog.

Fig. 21.9 Creating a virtual directory in PWS in Edit Directory.

21.8 Apache Web Server3


The Apache Web server, maintained by the Apache Software Foundation, is currently the most popular Web server because of its
stability, efficiency and portability. It is an open source product (i.e., software that can be freely obtained and customized) that runs
on UNIX, Linux and Windows platforms.
To install the Apache Web server, visit www.apache.org. For instructions on installing Apache, visit www.deitel.com.
After installing the Apache Web server, start the application to serve Web pages. From the Start menu, successively select
Programs, Apache httpd Server, Control Apache Server and Start. If the server starts success- fully, a command-prompt
window opens stating that the service is starting (Fig. 21.10). To stop the Apache Web server, from the Start menu, successively
select Programs, Apache httpd Server, Control Apache Server and Stop.

You might also like