cita 310 section 5

12
CITA 310 Section 5 Virtual Hosts and Virtual Directories (Selected Topics from Textbook Chapter 6)

Upload: dexter-bennett

Post on 01-Jan-2016

33 views

Category:

Documents


2 download

DESCRIPTION

CITA 310 Section 5. Virtual Hosts and Virtual Directories (Selected Topics from Textbook Chapter 6). Virtual Hosts. When Apache is configured for only one Web site or URL, it functions as a single main server. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CITA 310 Section 5

CITA 310 Section 5

Virtual Hosts and Virtual Directories(Selected Topics fromTextbook Chapter 6)

Page 2: CITA 310 Section 5

Virtual Hosts When Apache is configured for

only one Web site or URL, it functions as a single main server.

With virtual hosts, Apache functions as if it were a series of multiple, separate servers, each devoted to a URL.

Page 3: CITA 310 Section 5

Configuring Virtual Hosts You configure each virtual host by

adding a VirtualHost container for it in the Apache configuration file.

The opening VirtualHost directive specifies the IP address and an optional port number in which this virtual host should listen.

Page 4: CITA 310 Section 5

IP-Based Virtual Hosts Useful for flexibility because if

each host has its own unique IP address, you can easily move the host to a different Web server.

It is getting more expensive to get multiple IP addresses from an ISP.

Page 5: CITA 310 Section 5

Port-Based Virtual Hosts

Associate each new Web site with a port above 1023.

Because it requires a user to add the port number, it is not a popular method.

Page 6: CITA 310 Section 5

Name-Based Virtual Hosts 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 hosts with a single IP address.

It is the most common method of hosting.

Page 7: CITA 310 Section 5

IP-Based Virtual Host Example <VirtualHost 192.168.0.150>ServerName research.cita.comDocumentRoot htdocs/research</VirtualHost>

Page 8: CITA 310 Section 5

Port-Based Virtual Host Example Listen 8080 <VirtualHost 127.0.0.1:8080>DocumentRoot htdocs/test</VirtualHost>

Page 9: CITA 310 Section 5

Name-Based Virtual Host Example NameVirtualHost 127.0.0.1:80 <VirtualHost 127.0.0.1:80> ServerName www.cita.comDocumentRoot htdocs</VirtualHost> <VirtualHost 127.0.0.1:80>ServerName test.cita.comDocumentRoot htdocs/test</VirtualHost>

Page 10: CITA 310 Section 5

ServerAlias Directive The ServerAlias directive sets the

alternate names for a host, for use with name-based virtual hosts.

The ServerAlias may include wildcards, if appropriate.

Page 11: CITA 310 Section 5

Configuring a Virtual Directory in Apache The following associates the virtual

directory called testdir with the location of the directory

Alias /testdir C:/testdir Then it configures the directory<Directory C:/testdir>

Order allow,deny <-- no space in between

Allow from all

</Directory>

Page 12: CITA 310 Section 5

Redirection The Redirect directive maps an old

URL into a new one by asking the client to re-fetch the resource at the new location.

The old URL is a path beginning with a slash. A relative path is not allowed.

Example: Redirect /google http://www.google.com