Top Banner
Web Servers 1-1 Web Servers Xingquan (Hill) Zhu [email protected]
44

Web Servers Xingquan (Hill) Zhu [email protected]

Dec 30, 2015

Download

Documents

bevis-hopper

Web Servers Xingquan (Hill) Zhu [email protected]. Outline. Introduction HTTP Request Type Web Servers Microsoft IIS Apache Web Server Client-Side Scripting vs Server-Side Scripting Requesting Documents PhP. Introduction. Web server Responds to client requests by providing resources - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-1

Web Servers

Xingquan (Hill) [email protected]

Page 2: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-2

Outline

Introduction HTTP Request Type Web Servers

Microsoft IIS Apache Web Server

Client-Side Scripting vs Server-Side Scripting Requesting Documents

PhP

Page 3: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-3

Introduction Web server

Responds to client requests by providing resources

URL (Uniform Resource Locator) scheme: object-address

Web server and client communicate with platform-independent Hypertext Transfer Protocol (HTTP)

http://www.someschool.edu/someDept/pic.gif

host name path name

Page 4: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-4

Introduction: HTTP

HTTP: hypertext transfer protocol

Web’s application layer protocol

client/server model client: browser that

requests, receives, “displays” Web objects

server: Web server sends objects in response to requests

PC runningExplorer

Server running

Apache Webserver

Mac runningNavigator

HTTP request

HTTP request

HTTP response

HTTP response

Page 5: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-5

Introduction: HTTP RequestInitiate TCP Connection:

a small packet Hand shaking

Request File: Send HTTP request

Persistent vs non-psersistentKeep-alive on/off

time to transmit file

initiate TCPconnection

RTT

requestfile

RTT

filereceived

time time

GET /somedir/page.html HTTP/1.1Host: www.someschool.edu User-agent: Mozilla/4.0Connection: close Accept-language:fr

(extra carriage return, line feed)

Page 6: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-6

Introduction: HTTP Request Type

Request methods Get

• Retrieve and send client form data to Web server• Form data is to be encoded (by a browser) into a

URL

• http://www.google.com/search?hl=en&q=FAU&btnG=Google+Search

• 1024 characters post

• Post data to a server-side form handle– As data attachment

• Form data is to appear within a message body • Secure

Page 7: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-7

Introduction: Web servers

Page 8: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-8

Microsoft IIS

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

Page 9: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-9

IIS General home directory C:\inetput\wwwroot\ Can be accessed via

• http://localhost/mydocument.html• http://ip.ip.ip.ip/mydocument.html

Page 10: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-10

Virtual Directory

Page 11: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-11

Virtual Directory

Page 12: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-12

Virtual Directory

Page 13: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-13

Directory Properties

Page 14: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-14

Apache Server

Currently the most popular Web server Stability Efficiency Portability Open-source

Apache Server Installation

Page 15: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-15

Page 16: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-16

Select “HTTP Server”

Page 17: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-17

Select “Download! From a mirror”

Page 18: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-18

Select Apache Server 2.0.59 Win32 Binary and download

Save to your local disk

Apache_2.0.59-win32-x86-no_ssl.msi

Page 19: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-19

Apache Installation

Page 20: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-20

Apache installation

Page 21: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-21

Apache installation

Page 22: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-22

Apache installation

Page 23: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-23

Select apache directory

Page 24: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-24

Apache Directory

Page 25: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-25

Install

Page 26: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-26

Done

Page 27: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-27

Apache Configuration Where is it?

Page 28: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-28

Configuration: httpd.conf

Page 29: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-29

Configuration: httpd.conf Web address

http://localhost/directory/.. 10.20.30.40/directory/

startruncmdipconfig/all The default directory

Document Root: • H:/Program Files/Apache Group/Apache2/hotdocs

http://localhost or http://127.0.0.1/ Aliases

Map a local directory to a web directory Alias /home "h:/xqzhu/apache/homepage/“ Difference between /home and /home/

Access control Order Allow and Deny

• Allow from host host …• Deny from host host host …• Order allow, denyvs order deny, allow

– order allow,deny – allow from 123.156 – deny from all

Page 30: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-30

Configuration: httpd.conf Apply access control to directories

<Directory "H:/xqzhu/apache/homepage/"> Options Indexes Order allow, deny Allow from all</Directory>--------------------------------------------<Directory "d:/apache/test/">

Options IndexesOrder allow, denyDeny from 127.0.0.1Allow from all

</Directory>----------------------------------------------

Options: none, indexesQuestion? How to publish a web site content

directory?

Page 31: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-31

Configuration: httpd.conf UserDir:

The name of the directory that is appended onto a user's home directory if a ~user request is received

On Windows NT• UserDir "My Documents/My Website"

DirectoryIndex sets the file that Apache will serve if a directory is requested.

• Forbid listing a directory http://www.cse.fau.edu/~xqzhu DirectoryIndex index.html goog.html

Question again? How to publish a web site content directory?

Make sure that you reset the server each time you make the changes

Page 32: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-32

Service related parameters: httpd.conf

Listen a specific port Listen 8080

The number of seconds before receives and sends time out Timeout 300

Whether or not to allow persistent connections KeepAlive On KeepAliveTimeout 15

Page 33: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-33

Outline

Introduction HTTP Request Type Web Servers

Microsoft IIS Apache Web Server

Client-Side Scripting vs Server-Side Scripting Requesting Documents

PhP

Page 34: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-34

Client-Side Scripting vs Server-Side Scripting Client-side scripts (most fancy effects are here,

but browser dependent) Validate user input Reduce requests needed to be passed to server Enhance Web pages with DHTML, ActiveX controls,

and applets JavaScript, VBScript, Java Applet There are many things client-side scripts cannot do…

Server-side scripts (file and database access) Executed on server Generate custom response for clients Wide range of programmatic capabilities Functionality PHP (Hypertext Preprocessor), ASP (Active Server

Pages), JSP (Java Server Pages)

Page 35: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-35

Requesting Documents

Requesting five different documents XHTML ASP.NET Perl PHP Python

http://localhost/home/php/myphp.php

Page 36: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-36

PHP

Server must install PHP Must lead Apache to find the PHP, in

case there is a need to interpret PHP script Binding PhP with Apache Server

PHP Installation Configuration

Page 37: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-37

PHP

Page 38: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-38

Download windows binaries 5.1.6PHP 5.1.6 zip package

Page 39: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-39

Unzip the file to a local directory, say h:/php

Page 40: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-40

Change php.ini-recommended Change php.ini-recommended to

php.ini

php.ini is the configuration file of PHP

Page 41: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-41

Let Apache know where PHP is

Open httpd.conf (Apache configuration) Find out “#PhP module” Add following two lines below “# LoadModule” LoadModule php5_module

"h:/php/php5apache2.dll“ AddType application/x-httpd-php .php

Then you are basically good to go http://localhost/home/php/form.html

Page 42: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-42

Php.ini configuration Show all errors

error_reporting = E_ALL The separator used in PHP generated URLs

Default “&” arg_separator.output = "&amp;"

Separator(s) used by PHP to parse input URLs Default “&” arg_separator.input = ";&"

Whether to allow HTTP file upload file_uploads = On

Temporary directory for HTTP file upload upload_tmp_dir =“directory”

Numerous features related to PHP, will be addressed at later stage

Page 43: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-43

Pluto server

Directly put xxx.php file under any directory you like, Pluto has PhP already. http://student.cse.fau.edu/~yourid/

cop3813/hw6/myphp.php How to program PhP?

Page 44: Web Servers Xingquan (Hill) Zhu xqzhu@cse.fau

Web Servers 1-44

Outline

Introduction HTTP Request Type Web Servers

Microsoft IIS Apache Web Server

Client-Side Scripting vs Server-Side Scripting Requesting Documents

PhP