Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CITA 310 Section 5 Virtual Hosts and Virtual Directories (Selected Topics from Textbook Chapter 6)"— Presentation transcript:

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

2 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.

3 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.

4 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.

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.

6 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.

7 IP-Based Virtual Host Example ServerName research.cita.com DocumentRoot htdocs/research

8 Port-Based Virtual Host Example Listen 8080 DocumentRoot htdocs/test

9 Name-Based Virtual Host Example NameVirtualHost 127.0.0.1:80 ServerName www.cita.com DocumentRoot htdocs ServerName test.cita.com DocumentRoot htdocs/test

10 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.

11 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 Order allow,deny <-- no space in between Allow from all

12 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


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

Similar presentations


Ads by Google