1 / 12

CITA 310 Section 5

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.

Download Presentation

CITA 310 Section 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 • <VirtualHost 192.168.0.150>ServerName research.technowidgets.comDocumentRoot htdocs/research</VirtualHost>

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

  9. Name-Based Virtual Host Example • NameVirtualHost 127.0.0.1:80 <VirtualHost 127.0.0.1:80> ServerName localhostDocumentRoot htdocs</VirtualHost> <VirtualHost 127.0.0.1:80>ServerName test.cita.eduDocumentRoot htdocs/test</VirtualHost>

  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 <Directory C:/testdir> Order allow,deny <-- no space in between Allow from all </Directory>

  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 case-sensitive path beginning with a slash. A relative path is not allowed. • Example: Redirect /google http://www.google.com

More Related