360 likes | 570 Views
Configuring a Web Server. Overview. Understand how a Web server works Install IIS (Internet Information Services) and Apache Web servers Examine the IIS and Apache properties Host multiple Web sites Configure new Web sites in IIS and Apache Understand virtual directories.
E N D
Overview • Understand how a Web server works • Install IIS (Internet Information Services) and Apache Web servers • Examine the IIS and Apache properties • Host multiple Web sites • Configure new Web sites in IIS and Apache • Understand virtual directories
How a Web Server Works • HTTP (Hypertext Transfer Protocol) defines how information is passed between a browser and a Web server • The two most popular Web servers are • Apache from Apache Software Foundation • Internet Information Services (IIS) from Microsoft • Almost two-thirds of all Web servers use Apache
Understanding HTTP • Each Web server has a root, which is where you store the HTML documents • The current version of HTTP is 1.1 • HTTP is a stateless protocol, meaning that each Web page sent is independent of every other Web page sent • This makes it more challenging to create a shopping cart application
Understanding HTTP • HTTP 1.1 supports persistent connections • This allows the browser to receive multiple files in one TCP connection (without generating multiple connections) • This can speed up communication • Although you see a single page in your browser, it can be composed of many text and image files
` Client ( (Browser) Web Server Understanding HTTP Establishing a connection • The user types http://www.yyy.com/hello.htm in the browser • The Web browser contact the DNS to resolve the address • When the browser sends a request to a Web server, it looks like: GET /hello.htm HTTP/1.1 Host: www.technowidgets.com • The above requests the hello.htm file from the root of the Web server • It specifies the host of www.technowidgets.com • There could be multiple hosts at the IP address
Understanding HTTP • The following shows some of the headers along with the HTML that the Web server would send: HTTP/1.1 200 OK Server: Microsoft-IIS/5.0 Content-Type: text/html Last-Modified: Fri, 17 May 2005 18:21:25 GMT Content-Length: 43 <html><body> Hello, World </body></html> • The headers contain information about the page
Features in Apache • Apache 1.3 was used for many years but version 2.0 was released in 2001 • Apache can also be used as a proxy server • A proxy server isolates your real Web server from the Internet • The request is taken from the Internet and it is transferred to the Web serer • Apache 2.0 has • Better support for Windows • Support for IPv6 • Simplified configuration • Unicode support in Windows • Multilanguage error responses • Apache supports many programming languages such as Perl and PHP
Features in IIS Internet Information Services • IIS versions associated with Windows versions • Windows NT – IIS 4.0 • Windows 2000 – IIS 5.0 • Windows Server 2003 – IIS 6.0 • Increased security • Default permits only HTML documents • Support for IPv6 • SMTP can be easily added so you can send e-mail from your Web pages
Components in IIS • File Transfer Protocol (FTP) server • To transfer files between user and server • FrontPage 2000 Server Extensions • Used by programs to transfer files to and from a Web site • SMTP Service • World Wide Web Server
Installing Apache • Apache can be installed when you install Linux • If you install it from the Red Hat CD, the directories will be consistent with other server applications • If you download it from the Apache Web site, you have to compile it and install it
Starting Apache • By default, Apache does not start after you install it • The following table has a list of commands
Apache Properties- • Apache configuration is divided into three sections: • Global Environment • Controls the server overall operation • Rarely requires modification • Main Server Configuration • Contains the configuration information for the default server • Virtual Hosts • Contains setting for virtual hosts (virtual servers) in IIS • When we create a new web site in Apache we create a virtual host
Apache Properties-Global Environment • There are several global setting for configuring Apache • ServerRoot • Shows the directory location of server files • KeepAlive • Indicates whether Apache should maintain a persistent connection • Listen • Determines the port number for the server • Default is 80
Apache Properties-Main Server Configuration • The main server configuration describes the default server • User • Shows the user name that Apache employs when someone requests a Web page • The default is apache • ServerAdmin • E-mail address of administrator root@localhost • ServerName • DNS host name or IP address of server • DocumentRoot • Directory where the Web pages are stored
Minimal Apache Configuration • Add a ServerName in /etc/httpd/conf/httpd.conf • Add apachectl start to /etc/rc.d/rc.local • You can also just type apachectl start
Hosting Multiple Web Sites • A single server can support multiple Web sites • For multiple Web Sites to exist on the same computer, each site must be distinct • Distinct by Port number • Distinct by IP address • Distinct by based name or host name
Hosting Multiple Web Sites by IP Address • Useful for flexibility because if each domain has its own unique IP address, you can easily move the domain to a different Web server • You can create multiple IP addresses on a single NIC • Referred to as virtual IP addresses • It is getting more expensive to get multiple IP addresses from an ISP
Hosting Multiple Web Sites by Host Name • Multiple host names can be associated with a single IP address • Getting a single IP address from your ISP is relatively inexpensive • You can host an almost unlimited number of domains with a single IP address • It is the most common method of hosting
Configuring a Virtual Directory in Apache • A Web directory that is not physically located beneath the Web root (\inetpub\wwwroot) • Maybe in a different directory, different computer, different Server with different URL • The following associates the virtual directory called prod with the location of the directory Alias /prod/ “/var/www/prod/” • Then it configures the directory <Directory “/var/www/prod”> AllowOverride None Order allow, deny Allow from all </Directory>
Summary • Web servers use HTTP to send HTML documents • IIS is from Microsoft while Apache is from Apache Software Foundation • IIS modifications are made through property pages • Apache modifications are typically made by changing /etc/httpd/conf/httpd.conf
Summary • You can create multiple Web sites on a single computer by adding port numbers, IP addresses, and/or host names • Virtual directories are directories that appear to be located beneath the root, yet are physically located elsewhere
Errors in the book • Page 284-285 use the following addresses: • For mail use 192.168.0.200 + Your HD Number • For web1 use 192.168.0.x where x = Your HD Number • For research use 192.168.0.150 + Your HD Number
Web server Linux Directory SetupUpon completion you must have the following file structure Var/www html research prod web1 Index.html Index.html Index.html Index.html home User(steve) Public_html Index.html
Labs – LinuxInstalling and configuring the server • Make sure your DNS is installed properly • Installing Web servers • Most likely already installed • Start the server (page 262) • Configure the server name, make sure Apache starts automatically • Create a default web page for Apache (page 263) http://www.yyy.com or http://localhost should work!
Labs – LinuxConfigure the new Web • Create a directory to store the site (/var/www) Page 282 • Create web pages for the new web sites (page 283) • Using IP Addressing (page 284) • Create a virtual host research.yyyy.com • Using Host name • Create a virtual host name • Configure the web page (as appears on page 287)
Labs – LinuxConfigure virtual directories • A Web directory that is not physically located beneath the Web root (\inetpub\wwwroot) • Maybe in a different directory, different computer, different Server with different URL • The following associates the virtual directory called prod with the location of the directory Alias /prod/ “/var/www/prod/” • Then it configures the directory <Directory “/var/www/prod/”> AllowOverride None Order allow,deny Allow from all </Directory> Must have a SLASH! Must have no SPACE! Web1.yyyy.com/prod should work!
Labs – Linux Projects using Apache • General note: Many of these steps should already work at this time. • Project 6-4 • IN this project you create a web page and then request the web page using Telnet/ • Create a file called Hello.htm • To test your work, type: • />telnet localhost 80 • Then type: • />Get /hello.htm HTTP/1.1 • /> HOST: www.yyy.com • HOST: www.yyy.com -> The telnet session should NOT die immediately! • Project 6-5 • To test your work, type local http://localhost//products/hello.htm ; your HELLO page should pop up • Project 6-6 • Allow multiple users have their own web pages. Create a directory called public_html with mode 755. • To test your work, type http://localhost/~cbranco\ -> must generate a VALID WEB PAGE! • Project 6-7 • To test your work, type http://localhost/prod\
Labs – Linux Testing your labs: • Upon completion, the following should work: • http://192.168.0.150 pointing to RESEARCH web page • http://192.168.0.100 pointing to DEFAULT web page • http://research.yyy.com pointing to RESEARCH web page • http://www.yyy.com pointing to DEFAULT web page • http://web1.yyy.com pointing to WEB1web page • http://web1.yyy.com/prod/ pointing to RESEARCH web page (must have the last slash) • http://localhost pointing to DEFAULT web page
Notes for Windows • Page 284-285 use the following addresses: • For mail use 192.168.0.200 + Your HD Number • For web1 use 192.168.0.100 + Your HD Number • For research use 192.168.0.150 + Your HD Number
Labs – Windows; Projects using IIS • Make sure IIS is installed • Check c:/inetpub; if the directory does not exist that means you have to install IIS • To install IIS refer to page 253; Install IIS • After installing IIS you must see the c:/inetpub directory • Continue projects 6-1 and 6-2 • Create a web page/ request a web page using Telnet/ Create a file called Hello.htm • To test your work type : />telnet localhost 80 • Then type: • />Get /hello.htm HTTP/1.2 • /> HOST: www.yyy.com • At this point the telnet session should NOT die immediately! • Make sure the session is closed after 2 minutes (120 sec) • Make sure the header reads Version 5. • Then do Project 3. • Create a custom page for Error 404 and test it – if the page does not exist, then the error should appear • Test: http://localhost/h.html -> must generate ERROR- NOT FOUND! • type http://localhost The default error message should pop up