Apache Server for Windows Little Black Book:Configuring Virtual Hosts
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Apache Server for Windows Little Black Book
(Publisher: The Coriolis Group)
Author(s): Greg Holden with Matthew Keller
ISBN: 1576103919
Publication Date: 01/01/99
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Chapter 4Configuring Virtual Hosts
If you need an immediate solution to:
Applying For A Domain Name
Registering With InterNIC Using whois
Using The Domain Name Registration Wizard
Using ServerPath For Older Browsers
Setting Up Multiple Server Daemons
Keeping Apache From Performing DNS Lookups
Using One Daemon With Virtual Hosts
Using Multiple Site Names: Name-Based
Using Multiple IP Addresses: IP-Based
Configuring One IP Address With Multiple Names
Configuring Two IP Addresses With One Or More Names
Setting Up A Default Virtual Host
Assigning An IP Address To A Name-Based Vhost
Listening On Different Ports
Debugging With the -s Switch
In Brief
Apache And Virtual Hosts
The term virtual host has been mentioned several times in previous chapters. However, the subject of virtual hosting is so important that it deserves a detailed examination. Apache was one of the first servers to support virtual hosts (often called vhosts), which are a powerful way to enhance Web service. This chapter will explain what vhosts are, how to configure them, and how to understand related subjects such as the Domain Name Service (DNS) and IP-based hosting versus name-based hosting.
A Webmaster is often called upon to serve more than one Web site, either on the Internet or on an intranet. Internet Service Providers (ISPs) in particular might serve dozens or even hundreds of sites, many of which have their own domain names and Webmasters. This would be a terribly expensive proposition if a single computer could serve only one site at a time: www.company1.com would have to have its own computer, as would www.company2.com, and so on.
Virtual-host technology enables a single computer running a single Apache Hypertext Transfer Protocol (HTTP) daemon to actually serve multiple Web sites. Typically, Apache is configured to run a primary Web site and then one or more virtual hosts. By using the <VirtualHost> directive, you can assign each vhost a unique identity in the form of either an IP address or a domain name (or both). Each virtual site can also be assigned a separate Webmasters email address and document root directory, as in the following example:
NameVirtualHost 100.100.100.1
<VirtualHost www.acme.com>
ServerName www.acme.com
ServerAlias www.acmeinc.com
</VirtualHost>
TIP: Here and elsewhere in this chapter, the domain names and IP addresses are intentionally made-up. They arent intended to represent real addresses.
The result of using virtual hosts is that Apache can be set up to serve www.primarysite.com (the main site), www.client1.com (a virtual host), www.client2.com (a virtual host), and so on.
Apache was the first Web server to provide for virtual hosting out of the box. Its been a boon to ISPs, many of whom sell domain names and Web sites as part of their business. Theyre actually selling virtual host sites, and many of them reside on the same machine.
Concepts Behind Virtual Hosting
Traditionally, a networked computer has a single name and a single network interface card. However, one of the ideas that makes virtual hosting work is that a computer can have more than one name. In a sense, a virtual host is just an alternate name for your computer. The computer can respond to greg.company.com, and Apache can direct you to the root directory for that site; through virtual hosting, it can also respond to john.apache.com, and Apache can direct you to the document root for that virtual hosts name. This is called a name-based virtual host.
One Windows computer can also be assigned multiple IP addresses (which is analogous to a home having more than one telephone number). This is called an address or IP-based virtual host.
Virtual hosts get complicated when one or more of the following occurs:
A computer with an IP address such as 10.0.0.1 has more than one name assigned to it: name1.domain.com, name2.domain.com, and so on.
A computer has multiple IP addresses: 10.0.0.1, 10.0.0.2, and so on.
In any of these cases, domain names need to be registered and correctly matched with the correct IP address(es). A Domain Name System (DNS) server is needed to route a browser to the correct virtual host.
Its important to note that in Windows 95, each machine has to be equipped with a separate network interface card for each IP address. Windows 98 does support multiple IP addresses. In Windows NT 4 Server or Workstation, you can use multiple network cards (Workstation supports up to four cards; Server supports more than four), but they arent necessary. Rather, NT has built-in support for IP aliasing (assigning multiple IP addresses to a single domain name).
Performance And Other Considerations
The big advantage to hosting virtual sites on one computer is economic. Its simply far more cost-effective to host three virtual sites on one computer, for instance, than it is to use three computers.
However, there are some potential complications to running virtual sites, including the following:
If you want to do your own virtual hosting, you have to have a permanent connection to the Internet rather than a sporadic dial-up connection. Otherwise, youll have to find out if your ISP supports virtual hosting.
If one site receives especially heavy traffic, performance for all sites will decrease.
If the server goes down, all of the sites it hosts become unavailable until server restart.
Sites that are expected to receive a high number of hits or that need to serve big files such as video clips should be placed on dedicated servers for optimum performance.
Without the virtual host option, an ISP would have only a few unattractive options for letting customers serve their own Web sites:
Put the customers site on a port other than 80, as in http://www.client.com:8080.
Give the clients site a URL that makes it obviously part of the ISPs domain, such as http://www.provider.com/~client.
Assign a dedicated host to the customers site.
Some of these options are feasible, but for most applications, virtual sites offer the most elegant and cost-effective solution.
Previous
Table of Contents
Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.
Wyszukiwarka
Podobne podstrony:
083 0862010 01 02, str 083 086Lesson Plan 083 Text082 086 kw2qrdb2yngc6cdsn4p4ffv4hyp23fkrkawat3i086 088F G 083083 092086 11 (3)więcej podobnych podstron