Anzeige
Anzeige

Más contenido relacionado

Anzeige

Ch-1_.ppt

  1. 1 Berihun M. Lecturer [BSc, MSc(CS,IT)] Chapter 1 Web Servers (Apache and IIS)
  2. 2 1. Introduction 2. HTTP Transactions 3. System Architecture/ Multitier Application Architecture 4. Client-Side Scripting versus Server-Side Scripting 5. Accessing Web Servers 6. Microsoft Internet Information Services express and WebMatrix 7. Apache, MySQL and PHP Installation 8. Apache Web Server 9. Requesting Documents Outline  XHTML  ASP  Perl  Python  PHP
  3. Objectives • In this lesson, you will learn: – To understand a Web server’s functionality. – To introduce Microsoft Internet Information Services (IIS) and Apache Web server. – To learn how to request documents from a Web server.
  4. 1 Introduction • Web server – Responds to client requests by providing resources • URI (Uniform Resource Identifier) • Web server and client communicate with platform- independent Hypertext Transfer Protocol (HTTP)
  5. 5 Cont,.. • A web server responds to client requests (typically from a web browser) by providing resources such as XHTML documents. • When users enter a Uniform Resource Locator (URL) address, such as www.deitel.com, into a web browser, they are requesting a specific document from a web server. • The web server maps the URL to a resource on the server (or to a file on the server’s network) and returns the requested resource to the client. • A web server and a client communicate using the platform- independent Hypertext Transfer Protocol (HTTP), a protocol for transferring requests and files over the Internet or an intranet.
  6. 6 HTTP Transactions • The HTTP protocol allows clients and servers to interact and exchange information uniformly and reliably. • HTTP uses URIs (Uniform Resource Identifiers) to identify data on the Internet. • URIs that specify document locations are called URLs (Uniform Resource Locators). Common URLs refer to files, directories, or objects that perform complex tasks, such as database lookups. • A URL contains information that directs a browser to the resource that the user wishes to access. • http:// indicates that the resource is to be obtained using the HTTP protocol. What is HTTP Transactions?
  7. 7 HTTP Transactions (Cont.) • Fully qualified hostname – the name of the server on which the resource resides called the host. • A hostname is translated into an IP address—a unique numerical value which identifies the server much as a telephone number uniquely defines a particular phone line – Translation is performed by a domain name system (DNS) server—a computer that maintains a database of hostnames and their corresponding IP addresses—and the process is called a DNS lookup • The remainder of the URL after the hostname specifies both the name of the requested resource and its path, or location, on the web server • For security reasons the path normally specifies the location of a virtual directory. The server translates the virtual directory into a real location on the server (or on another computer on the server’s network), thus hiding the true location of the resource • Some resources are created dynamically and do not reside anywhere on the server
  8. 8 HTTP Transactions (Cont.) • When given a URL, a web browser performs a simple HTTP transaction to retrieve and display the web page found at that address. • HTTP method get indicates that the client wishes to obtain a resource from the server. The remainder of the request provides the path name of the resource (e.g., an XHTML document) and the protocol’s name and version number (HTTP/1.1). • Any server that understands HTTP can receive a get request and respond appropriately. • HTTP status code 200 indicates success. Status code 404 informs the client that the web server could not locate the requested resource. A complete list of numeric codes indicating the status of an HTTP transaction can be found at www.w3.org/Protocols/rfc2616/rfc2616- sec10.html
  9. 9 HTTP Transactions (Cont.) • In a response, the server sends one or more HTTP headers, which provide additional information about the data that will be sent. • Multipurpose Internet Mail Extensions (MIME) is an Internet standard that specifies data formats so that programs can interpret data correctly. The MIME type text/plain indicates that the sent information is text that can be displayed directly, without any interpretation of the content as XHTML markup. The MIME type image/jpeg indicates that the content is a JPEG image. When the browser receives this MIME type, it attempts to display the image. • The header or set of headers is followed by a blank line, which indicates to the client browser that the server is finished sending HTTP headers.
  10. 10 Fig. 21.1 | Client interacting with web server. Step 1: The GET request.
  11. 11 Fig. 21.2 | Client interacting with web server. Step 2: The HTTP response.
  12. 12 21.2 HTTP Transactions (Cont.) • Two most common HTTP request types – get and post – get request typically gets (or retrieves) information from a server. Common uses of get requests are to retrieve an XHTML document or an image, or to fetch search results based on a user-submitted search term. – post request typically posts (or sends) data to a server. Common uses of post requests are to send information to a server, such as authentication information or data from a form that gathers user input. – An HTTP request often posts data to a server-side form handler that processes the data. – A get request sends information to the server as part of the URL in a query string. A ? separates the query string from the rest of the URL in a get request. A name/value pair is passed to the server with the name and the value separated by an equals sign (=). If more than one name/value pair is submitted, each pair is separated by an ampersand (&). – A get request may be initiated by submitting an XHTML form whose method attribute is set to "get", or by typing the URL (possibly containing a query string) directly into the browser’s address bar – A post request is specified in an XHTML form by the method "post". The post method sends form data as an HTTP message, not as part of the URL. – A get request limits the query string to a specific number of characters (2083 in IE; more in other browsers). – Large pieces of information must be sent using the post method.
  13. 13 Software Engineering Observation  The data sent in a post request is not part of the URL and the user can’t see the data by default.  However there are tools available that expose this data, so you should not assume that the data is secure just because a post request is used.
  14. 14 HTTP Transactions (Cont.) • Browsers often cache web pages so they can quickly reload the pages. • If there are no changes between the version stored in the cache and the current version on the web, this helps speed up your browsing experience.
  15. 15 Multitier Application Architecture • Web-based applications are multitier applications that divide functionality into separate tiers. Although tiers can be located on the same computer, the tiers of web-based applications typically reside on separate computers. • The bottom tier (also called the data tier or the information tier) maintains the application’s data. • The middle tier implements business logic, controller logic and presentation logic to control interactions between the application’s clients and its data. • Business logic in the middle tier enforces business rules and ensures that data is reliable before the server application updates the database or presents the data to users. Business rules dictate how clients can and cannot access application data, and how applications process data. • The top tier, or client tier, is the application’s user interface. In response to user actions, the client tier interacts with the middle tier to make requests and to retrieve data from the information tier. The client tier then displays the data retrieved for the user. The client tier never directly interacts with the information tier.
  16. 16 Fig. 21.3 | Three-tier architecture.
  17. 17 Client-Side Scripting Vs Server-Side Scripting • Client-side scripting can be used to validate user input, to interact with the browser, to enhance web pages by manipulating the DOM(Document object model) of a page, and to add Ajax(Asynchronous JavaScript And XML) functionality. • Client-side scripting does have limitations, such as browser dependency; • The browser or scripting host must support the scripting language and capabilities. • Client-side scripts can be viewed by the client by using the browser’s source-viewing capability. • Sensitive information, such as passwords or other personally identifiable data, should not be stored or
  18. 18 21.4 Client-Side Scripting versus Server-Side Scripting (Cont.) • Placing large amounts of JavaScript on the client can open web applications to attack and other security issues. • Code executed on the server often generate custom responses for clients. • Server-side scripting languages have a wider range of programmatic capabilities than their client-side equivalents. For example, server-side scripts often can access the server’s file directory structure, whereas client- side scripts cannot access the client’s directories. • Properly configured server-side scripts are not visible to the client; only XHTML and any client-side scripts are visible to the client.
  19. 19 Software Engineering Observation • Properly configured server-side script source code is not visible to the client; only XHTML and any client- side scripts are visible to the client.
  20. 20 Accessing Web Servers • To request documents from web servers, users must know the hostnames on which the web server software resides. • Users can request documents from local web servers or remote web servers. • Local web servers can be accessed through your computer’s name or through the name localhost—a hostname that references the local machine and normally translates to the IP address 127.0.0.1 (also known as the loopback address).
  21. 21 Microsoft Internet Information Services (IIS) • Microsoft Internet Information Services (IIS) is a web server that is included with several versions of Windows. • Installing IIS on a machine allows that computer to serve documents. • To install IIS 5.1 on Windows XP, you may need your original operating-system disk. For IIS 6.0 (Windows Server 2003) and IIS 7.0 (Windows Vista), the software should already be installed, but is also available on your installation disk. • You place documents that will be requested from IIS either in the default directory or in a virtual directory. A virtual directory is an alias for an existing directory that resides on the local machine or on the network. • In Windows Vista, before you can use IIS, you must enable the World Wide Web Publishing Service (W3SVC).
  22. 22 Apache HTTP Server • The Apache HTTP Server, maintained by the Apache Software Foundation, is currently the most popular web server. • It is open-source software that runs on UNIX, Linux, Mac OS X, Windows, and numerous other platforms. • Mac OS X and many versions of Linux come preinstalled with Apache. • You can obtain the Apache HTTP Server for a variety of platforms from httpd.apache.org/download.cgi. • All documents that will be requested from an Apache HTTP Server must be either in the default directory or in a directory for which an Apache HTTP Server alias is configured. • An alias is Apache’s equivalent to Microsoft IIS’s virtual directory. • It is a pointer to an existing directory that resides on the local machine or on the network. • The httpd.conf file contains all the information that the Apache HTTP Server needs to run correctly and serve web documents. • An introductory comment at the top of the httpd.conf file explains how the file is organized. • After this comment, the configuration information starts with the most important, global settings.
  23. HTTP Request Types • Request methods – Get  Retrieve and send client form data to the Web server – Post  Post data to a server-side form handler
  24. System Architecture • Multi-tier application (n-tier application) – Information tier (data or bottom tier) • Maintains data for the application • Stores data in a relational database management system (RDBMS) – Middle tier • Implements business logic and presentation logic • Control interactions between application clients and application data – Client tier (top tier) • Application’s user interface • Users interact directly with the application through the client tier
  25. Client-Side Scripting versus Server-Side Scripting • Client-side scripts – Validate user input • Reduce requests needed to be passed to server • Access browser • Enhance Web pages with DHTML, ActiveX controls, and applets • Server-side scripts – Executed on server – Generate custom response for clients – Wide range of programmatic capabilities – Access to server-side software that extends server functionality
  26. Accessing Web Servers • Request documents from Web servers – Host names – Local Web servers • Access through machine name or localhost – Remote Web servers • Access through machine name – Domain name or Internet Protocol (IP) address • Domain name server (DNS) – A computer that maintains a database of hostnames and their corresponding IP address
  27. 27 • Web server – Specialized software that responds to client requests by providing resources – When users enter URL into Web browsers, they request specific documents from Web server – Maps URL to file on server and returns requested document to client – Communicates with client using HTTP • Protocol for transferring requests and files over the Internet • Introduce three Web servers (Fig.1) – Internet Information Services (IIS), Personal Web Server (PWS) and Apache Web Server
  28. 28 Introduction IIS PWS Apache Company Microsoft Corporation Microsoft Corporation Apache Software Foundation Version 5.1 4.0 1.3.20 Released 2/17/00 12/4/97 5/21/01 Platforms Windows 2000 Windows XP Windows 95/98/ Millennium Edition (Me)/NT UNIX, Windows NT/2000, experimentally supports Windows 95/98 Brief description The most popular Web server for Windows 2000 & XP A basic Web server for publishing personal Web pages. Currently the most popular Web server. Price Included with Windows 2000 & XP Freeware. Packaged with Microsoft IIS in NT 4.0 Option Pack. Also included in Windows 98. Freeware. Fig. 1 Web servers discussed in this c hapter.
  29. 29 HTTP Request Types • Also known as request methods • Most popular are get and post – Retrieve and send client form data to Web server – get request • Sends form content as part of URL • Retrieves appropriate resource from Web server • Limits query to 1024 characters – post request • Updates contents of Web server (posting new messages to forum) • Has no limit for length of query • Not part of URL and cannot be seen by user
  30. 30 HTTP Request Types (Cont’d) • Posts data to server-side form handler • Browsers cache (save on disk) Web pages – Allows for quick reloading – Cache responses to get request – Do not cache responses to post request
  31. 31 System Architecture • Web server part of multi-tier application – Divide functionality into separate tiers • Logical groupings of functionality • Can reside on same computer or on different computers • Following diagrams illustrates 3-tier application
  32. 32 System Architecture (Cont’d) App lica tion M id dle tier Inform ation tie r Client tie r Da ta ba se Fig. 2 Three-tier application model.
  33. 33 System Architecture (Cont’d) • Information tier – Referred to as data tier or bottom tier – Maintains data for application – Stores data in relational database management system • Middle tier – Implements business logic and presentation logic – Controls interactions between application clients and application data – Acts as intermediary between data in information tier and application clients
  34. 34 System Architecture (Cont’d) • Middle tier, cont. – Controller logic • Processes client requests from top tier • Retrieves data from database – Presentation logic • Processes data from information tier • Presents content to client – Business logic • Enforces business rules – Dictates how clients can access application data and how applications process data • Ensures data validity before updating database
  35. 35 System Architecture (Cont’d) • Client tier – Referred to as top tier – Application’s user interface – Users interact with application through user interface – Interacts with middle tier to make requests and to retrieve data from information tier – Displays data to user
  36. 21.6.1 Microsoft Internet Information Services (IIS) 5.0 • FTP Site – Used for transferring large files across the Internet • HTTP Site – Used most frequently to request documents from Web servers • SMTP Virtual Server – Sends and receives electronic mail • Web Site Content Directory – Directory containing the documents that clients will view
  37. 37 Client-Side Scripting versus Server-Side Scripting • Client-side scripting – Validates user input – Accesses the browser – Enhances Web pages with ActiveX® controls, applets, etc. – Manipulates browser documents • Client-side validation – Reduces number of requests that need to be passed to server • Client-side scripting limitations – Browser dependency – Viewable to users through View Source command • JavaScript most popular client-side script
  38. 38 Client-Side Scripting versus Server-Side Scripting (Cont’d) • Server-side scripts – Provides programmers greater flexibility – Generates custom responses for clients – Contains greater programmatic capabilities than client-side equivalents – Has access to server-side software that extend server functionality
  39. 39 Accessing Web Servers • Requesting documents – Must know machine name on which Web server resides – Through local Web servers or remote Web servers – Through domain name or Internet Protocol (IP) address • Local Web server – Resides on users’ machines – Requests documents in two ways • Machine name • localhost – Host name that references local machine
  40. 40 Accessing Web Servers (Cont’d) • Remote Web server – Resides on different machines • Domain name – Represents group of hosts on Internet – Combines with how name (www) and top-level domain to from fully qualified host name • Top-level domain (TLD) – Describes type of organization that owns domain name • .com or .org • Fully qualified host name – Provides user friendly way to identify site on Internet
  41. 41 Accessing Web Servers (Cont’d) • IP address – Unique address for locating computers on Internet • Domain name server (DNS) – Maintains database of host names and corresponding IP addresses – Translates fully qualified host name to IP address • Known as DNS lookup
  42. 42 Microsoft Internet Information Services (IIS) • IIS 5.1 – Enterprise-level Web server – Included with Windows 2000 & Windows XP – Allows computer to serve documents • Internet Services Manager – Open Control Panel, double click Administrative Tools icon, then double click Internet Services Manager icon – Administration program for IIS – Place documents to be requested in default directory or virtual directory • Default: C:InetpubWwwroot • Virtual: alias for existing directory on local machine
  43. 43 Microsoft Internet Information Services (IIS) • Default FTP Site and Default Web Site – Permit transferring documents between computer and server – HTTP used frequently to request documents • Default SMTP Virtual Server – Allows for creation of mail server • Create virtual directory in Default Web Site – Most Web documents reside in Webpub directory • Right click Webpub, select New, then Virtual Directory • Initiates Virtual Directory Creation Wizard (Fig. 4) – Guides user through virtual directory creation process
  44. 44 Microsoft Internet Information Services (IIS) • Virtual Directory Alias (Fig. 5) – Enter name for virtual directory • Name should not conflict with an existing virtual directory • Web Site Content Directory (Fig. 6) – Enter path of directory containing Web documents • Access Permissions (Fig. 7) – Presents security level choices – Select access level appropriate for Web document
  45. 45 Microsoft Internet Information Services (IIS) • Access Permissions • Presents security level choices – Select access level appropriate for Web document – Read allows users to read and download files – Run Scripts allows scripts to run in directory – Execute allows applications to run in directory – Write allows Web page to accept user input – Browse allows users to navigate between documents – Read and Run Scripts selected by default
  46. 46 Microsoft Personal Web Server (PWS) • PWS – Scaled-down version of IIS – Intended for personal computers (PC) – Ideal for educational institutions, small businesses and individuals – Does not require PC to be used exclusively as Web server • Personal Web Manager (Fig. 8) – Administration program for PWS – Place documents to be requested in default directory or virtual directory • Default: C:InetpubWwwroot • Virtual: alias for existing directory on local machine
  47. 47 Apache Web Server • Apache – Maintained by Apache Software Foundation – Currently most popular Web server • Stable • Efficient • Portable – Successively select Start, Programs, Apache httpd Server, Control Apache Server and Start
  48. 48 Apache Web Server Fig. Starting the Apache Web server.
  49. 49 Requesting Documents • Requesting five different documents – XHTML – ASP.NET – Perl – PHP – Python
  50. 50 XHTML • IIS, PWS and Apache support XHTML • IIS or PWS – Copy test.html into directory that references virtual directory – Launch Internet Explorer and enter XHTML document’s location in Address field (Figs. 11 and 12) • Apache – Copy test.html to htdocs directory (default directory) – Launch Internet Explorer and enter XHTML document’s location in Address field (Fig. 13)
  51. 51 XHTML Fig. 21.11 Requesting test.html from IIS. Fig. Requesting test.html from PWS. Notice different URL’s in Address field localhost references local machine For IIS, we created virtual directory in Webpub directory
  52. 52 XHTML Fig. . Requesting test.html from Apache. Since htdocs is the default directory, we do not need to enter directory name in URL
  53. 53 Python • IIS, PWS and Apache support Python documents • IIS and PWS – Copy test.py into directory that references virtual directory – Launch Internet Explorer and enter Python document’s location in Address field (Figs. 19 and 20) • Apache – Copy test.py to cgi-bin directory • Python documents must reside in this directory – Launch Internet Explorer and enter Python document’s location in Address field (Fig. 21)
  54. 54 Python Fig. 19 Requesting test.py from IIS. Fig. 20 Requesting test.py from PWS.
  55. 55 Python Fig. 21 Requesting test.py from Apache.
  56. 56 PHP • IIS, PWS and Apache support PHP documents • IIS and PWS – Copy test.php into directory that references virtual directory – Launch Internet Explorer and enter PHP document’s location in Address field (Figs. 22 and 23) • Apache – Copy test.php to htdocs directory – Launch Internet Explorer and enter PHP document’s location in Address field (Fig. 24)
Anzeige