1 / 36

Chapter 21 - Web Servers (IIS, PWS and Apache)

Chapter 21 - Web Servers (IIS, PWS and Apache). Outline 21.1 Introduction 21.2 HTTP Request Types 21.3 System Architecture 21.4 Client-Side Scripting versus Server-Side Scripting 21.5 Accessing Web Servers 21.6 Microsoft Internet Information Services (IIS)

kamali
Download Presentation

Chapter 21 - Web Servers (IIS, PWS and Apache)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 21 - Web Servers (IIS, PWS and Apache) Outline 21.1 Introduction 21.2 HTTP Request Types 21.3 System Architecture 21.4 Client-Side Scripting versus Server-Side Scripting 21.5 Accessing Web Servers 21.6 Microsoft Internet Information Services (IIS) 21.7 Microsoft Personal Web Server (PWS) 21.8 Apache Web Server 21.9 Requesting Documents 21.9.1 XHTML 21.9.2 ASP 21.9.3 Perl 21.9.4 Python 21.9.5 PHP 21.10 Internet and World Wide Web Resources

  2. 21.1 Introduction • 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 • Compare three Web servers (Fig. 21.1) • Internet Information Services (IIS), Personal Web Server (PWS) and Apache Web Server

  3. 21.1 Introduction

  4. 21.2 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 (?x=y&z=w format) • Retrieves appropriate resource from Web server • Theoretically unlimited query length, but old proxies may limit query to 255 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

  5. 21.2 HTTP Request Types • 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

  6. HTTP protocol • HTTP messages are defined by the standard, and take the following form: HTTP-message = Request | Response Request = Request-Line *(( general-header | request-header | entity-header ) CRLF) CRLF [ message-body ] Response = Status-Line *(( general-header | response-header | entity-header ) CRLF) CRLF [ message-body ] Request-Line = Method SP Request-URI SP HTTP-Version CRLF Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF

  7. HTTP protocol • HTTP request methods are: Method = "OPTIONS" | "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "TRACE" | "CONNECT" | extension-method extension-method = token • The request header includes additional information: request-header = Accept | Accept-Charset | Accept-Encoding | Accept-Language | Authorization | Expect | From| Host | If-Match | If-Modified-Since | If-None-Match | If-Range | If-Unmodified-Since | Max-Forwards | Proxy-Authorization | Range | Referer | TE | User-Agent

  8. 21.3 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 diagram illustrates 3-tier application

  9. 21.3 System Architecture Fig. 21.2 Three-tier application model.

  10. 21.3 System Architecture • 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

  11. 21.3 System Architecture • 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

  12. 21.3 System Architecture • 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

  13. 21.4 Client-Side Scripting versus Server-Side Scripting • Client-side scripting • Validates user input • Accesses the browser • Enhances Web pages with 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

  14. 21.4 Client-Side Scripting versus Server-Side Scripting • 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

  15. Client-Side Scripting versus Server-Side • Server-side includes (SSI) (Apache) • Server generated documents written using a combination of XHTML and server directives enclosed in comments • <!--#include file='test.html' --> inserts the HTML file, test.html, at that point in the document • Other directives include conditional statements, printing statements and the ability to set variables • Only relatively simple functionality can be achieved using SSI • Not suitable for complex tasks • More suited to generating pages that have a similar appearance or structure • www.see.ed.ac.uk makes extensive use of SSI

  16. 21.5 Accessing Web Servers • Requesting documents • Must know Web server name • 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

  17. 21.5 Accessing Web Servers • 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

  18. 21.5 Accessing Web Servers • 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

  19. 21.8 Apache Web Server • Apache • Maintained by Apache Software Foundation • Currently most popular Web server • Stable • Efficient • Portable • To run under Windows, successively select Start, Programs, ApachehttpdServer, ControlApacheServer and Start (Fig. 21.10) • To run under Unix, the configuration file(s) should be edited and then httpd run (usually as part of the system autoboot sequence) • Configuration files specify server name, security options, location of the web tree, etc.

  20. 21.8 Apache Web Server Fig. 21.10 Starting the Apache Web server. (Courtesy of The Apache Software Foundation.)

  21. 21.9 Requesting Documents • Demonstrate requesting three different documents • XHTML, Perl and PHP • Discuss serving these documents using Apache

  22. This finds the document at the root of the Web server tree as specified in the configuration files 21.9.1 XHTML Fig. 21.13 Requesting test.html from Apache.

  23. 21.9.3 Perl • IIS, PWS and Apache support Perl documents • IIS and PWS • Copy test.pl into directory that references virtual directory (C:\Chapter21Examples) • Launch Internet Explorer and enter Perl document’s location in Address field (Figs. 21.16 and 21.17) • Apache • Copy test.pl to WWW/cgi-bin directory • Perl documents must reside in this directory • Launch Internet Explorer and enter Perl document’s location through cgiwrap in Address field (Fig. 21.18)

  24. cgi-bin is required in URL; it is not default directory. cgiwrap is used to increase security. The file is found in the user's WWW/cgi-bin directory. 21.9.3 Perl Fig. 21.18 Requesting test.pl from Apache.

  25. 21.9.5 PHP • IIS, PWS and Apache support PHP documents • IIS and PWS • Copy test.php into directory that references virtual directory (C:\Chapter21Examples) • Launch Internet Explorer and enter PHP document’s location in Address field (Figs. 21.22 and 21.23) • Apache • Copy test.php to WWW directory • Launch Internet Explorer and enter PHP document’s location in Address field (Fig. 21.24)

  26. 21.9.5 PHP Fig. 21.24 Requesting test.php from Apache.

  27. Chapter 29 - PHP Outline 29.1 Introduction 29.2 PHP 29.3 String Processing and Regular Expressions 29.4 Viewing Client/Server Environment Variables 29.5 Form Processing and Business Logic 29.6 Verifying a Username and Password 29.7 Connecting to a Database 29.8 Cookies 29.9 Operator Precedence 29.10 Internet and World Wide Web Resources

  28. Scripting delimiters Declare variable $name Single-line comment Function print outputs the value of variable $name 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 3 4 <!-- Fig. 29.1: first.php --> 5 <!-- Our first PHP script --> 6 7 <?php 8 $name = "Paul";// declaration 9 ?> 10 11 <html xmlns = "http://www.w3.org/1999/xhtml"> 12 <head> 13 <title>A simple PHP document</title> 14 </head> 15 16 <body style = "font-size: 2em"> 17 <p> 18 <strong> 19 20 <!-- print variable name’s value --> 21 Welcome to PHP, <?php print( "$name" );?>! 22 </strong> 23 </p> 24 </body> 25 </html> First.phpProgram Output

  29. 29.2 PHP

  30. Assign a string to variable $testString Assign a double to variable $testDouble Assign an integer to variable $testInteger Print each variable’s value 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 4 <!-- Fig. 29.3: data.php --> 5 <!-- Demonstration of PHP data types --> 6 7 <html xmlns = "http://www.w3.org/1999/xhtml"> 8 <head> 9 <title>PHP data types</title> 10 </head> 11 12 <body> 13 14 <?php 15 16 // declare a string, double and integer 17 $testString = "3.5 seconds"; 18 $testDouble = 79.2; 19 $testInteger = 12; 20 ?> 21 22 <!-- print each variable’s value --> 23 <?phpprint( $testString ) ?> is a string.<br /> 24 <?phpprint( $testDouble ) ?> is a double.<br /> 25 <?phpprint( $testInteger ) ?> is an integer.<br /> 26 27 <br /> 28 Now, converting to other types:<br /> 29 <?php 30 31 // call function settype to convert variable 32 // testString to different data types 33 print( "$testString" ); Data.php

  31. Call function settype to convert the data type of variable $testString to a double. Call function settype to convert the data type of variable $testString to an integer. Convert variable $testString back to a string Use type casting to cast variable $data to different types 34 settype( $testString, "double" ); 35 print( " as a double is $testString <br />" ); 36 print( "$testString" ); 37 settype( $testString, "integer" ); 38 print( " as an integer is $testString <br />" ); 39 settype( $testString, "string" ); 40 print( "Converting back to a string results in 41 $testString <br /><br />" ); 42 43 $value = "98.6 degrees"; 44 45 // use type casting to cast variables to a 46 // different type 47 print( "Now using type casting instead: <br /> 48 As a string - " . (string) $data . 49 "<br />As a double - " . (double) $data . 50 "<br />As an integer - " . (integer) $data ); 51 ?> 52 </body> 53 </html> Data.php

  32. Program Output

  33. Multiply variable $a by two using the multiplication assignment operator *=. Add 40 to variable $a using the addition assignment operator +=. 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 4 <!-- Fig. 29.4: operators.php --> 5 <!-- Demonstration of operators --> 6 7 <html xmlns = "http://www.w3.org/1999/xhtml"> 8 <head> 9 <title>Using arithmetic operators</title> 10 </head> 11 12 <body> 13 <?php 14 $a = 5; 15 print( "The value of variable a is $a <br />" ); 16 17 // define constant VALUE 18 define( "VALUE", 5 ); 19 20 // add constant VALUE to variable $a 21 $a = $a + VALUE; 22 print( "Variable a after adding constant VALUE 23 is $a <br />" ); 24 25 // multiply variable $a by 2 26 $a *= 2; 27 print( "Multiplying variable a by 2 yields $a <br />" ); 28 29 // test if variable $a is less than 50 30 if ( $a < 50 ) 31 print( "Variable a is less than 50 <br />" ); 32 33 // add 40 to variable $a 34 $a += 40; 35 print( "Variable a after adding 40 is $a <br />" ); Operators.php

  34. 36 37 // test if variable $a is 50 or less 38 if ( $a < 51 ) 39 print( "Variable a is still 50 or less<br />" ); 40 41 // test if variable $a is between 50 and 100, inclusive 42 elseif ( $a < 101 ) 43 print( "Variable a is now between 50 and 100, 44 inclusive<br />" ); 45 else 46 print( "Variable a is now greater than 100 47 <br />" ); 48 49 // print an uninitialized variable 50 print( "Using a variable before initializing: 51 $nothing <br />" ); 52 53 // add constant VALUE to an uninitialized variable 54 $test = $num + VALUE; 55 print( "An uninitialized variable plus constant 56 VALUE yields $test <br />" ); 57 58 // add a string to an integer 59 $str = "3 dollars"; 60 $a += $str; 61 print( "Adding a string to an integer yields $a 62 <br />" ); 63 ?> 64 </body> 65 </html> Operators.php

  35. Program Output

  36. 29.2 PHP

More Related