cita 310 section 5
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 PresentationTRANSCRIPT
CITA 310 Section 5
Virtual Hosts and Virtual Directories(Selected Topics fromTextbook Chapter 6)
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.
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.
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.
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.
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.
IP-Based Virtual Host Example <VirtualHost 192.168.0.150>ServerName research.cita.comDocumentRoot htdocs/research</VirtualHost>
Port-Based Virtual Host Example Listen 8080 <VirtualHost 127.0.0.1:8080>DocumentRoot htdocs/test</VirtualHost>
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>
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.
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>
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