Post on 30-Dec-2015
description
Web Servers 1-1
Web Servers
Xingquan (Hill) Zhuxqzhu@cse.fau.edu
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
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
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
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)
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
Web Servers 1-7
Introduction: Web servers
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
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
Web Servers 1-10
Virtual Directory
Web Servers 1-11
Virtual Directory
Web Servers 1-12
Virtual Directory
Web Servers 1-13
Directory Properties
Web Servers 1-14
Apache Server
Currently the most popular Web server Stability Efficiency Portability Open-source
Apache Server Installation
Web Servers 1-15
Web Servers 1-16
Select “HTTP Server”
Web Servers 1-17
Select “Download! From a mirror”
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
Web Servers 1-19
Apache Installation
Web Servers 1-20
Apache installation
Web Servers 1-21
Apache installation
Web Servers 1-22
Apache installation
Web Servers 1-23
Select apache directory
Web Servers 1-24
Apache Directory
Web Servers 1-25
Install
Web Servers 1-26
Done
Web Servers 1-27
Apache Configuration Where is it?
Web Servers 1-28
Configuration: httpd.conf
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
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?
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
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
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
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)
Web Servers 1-35
Requesting Documents
Requesting five different documents XHTML ASP.NET Perl PHP Python
http://localhost/home/php/myphp.php
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
Web Servers 1-37
PHP
Web Servers 1-38
Download windows binaries 5.1.6PHP 5.1.6 zip package
Web Servers 1-39
Unzip the file to a local directory, say h:/php
Web Servers 1-40
Change php.ini-recommended Change php.ini-recommended to
php.ini
php.ini is the configuration file of PHP
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
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 = "&"
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
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?
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