virtual-host.html revision f9b3be308809978f797e0c57b296147532a4313c
af84459fbf938e508fd10b01cb8d699c79083813takashi<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
af84459fbf938e508fd10b01cb8d699c79083813takashi<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
af84459fbf938e508fd10b01cb8d699c79083813takashi BGCOLOR="#FFFFFF"
af84459fbf938e508fd10b01cb8d699c79083813takashi TEXT="#000000"
af84459fbf938e508fd10b01cb8d699c79083813takashi LINK="#0000FF"
af84459fbf938e508fd10b01cb8d699c79083813takashi VLINK="#000080"
af84459fbf938e508fd10b01cb8d699c79083813takashi ALINK="#FF0000"
af84459fbf938e508fd10b01cb8d699c79083813takashi<!--#include virtual="header.html" -->
af84459fbf938e508fd10b01cb8d699c79083813takashiThis is the ability of a single machine to be a web server for multiple
af84459fbf938e508fd10b01cb8d699c79083813takashidomains. For example, an Internet service provider might have a machine
af84459fbf938e508fd10b01cb8d699c79083813takashicalled <CODE>www.serve.com</CODE> which provides Web space for several
af84459fbf938e508fd10b01cb8d699c79083813takashiorganizations including, say, <EM>smallco</EM> and <EM>baygroup</EM>.
af84459fbf938e508fd10b01cb8d699c79083813takashiOrdinarily, these groups would be given parts of the Web tree on www.serve.com.
af84459fbf938e508fd10b01cb8d699c79083813takashiSo smallco's home page would have the URL
af84459fbf938e508fd10b01cb8d699c79083813takashi<BLOCKQUOTE>
af84459fbf938e508fd10b01cb8d699c79083813takashi</BLOCKQUOTE>
af84459fbf938e508fd10b01cb8d699c79083813takashiand baygroup's home page would have the URL
af84459fbf938e508fd10b01cb8d699c79083813takashi<BLOCKQUOTE>
af84459fbf938e508fd10b01cb8d699c79083813takashi</BLOCKQUOTE>
af84459fbf938e508fd10b01cb8d699c79083813takashiFor esthetic reasons, however, both organizations would rather their home
af84459fbf938e508fd10b01cb8d699c79083813takashipages appeared under their own names rather than that of the service
af84459fbf938e508fd10b01cb8d699c79083813takashiprovider's; but they do not want to set up their own Internet links and
50cb7e2b30597f481fee57bac945190f06ebcc58jortonVirtual hosts are the solution to this problem. smallco and baygroup would
50cb7e2b30597f481fee57bac945190f06ebcc58jortonhave their own Internet name registrations, <CODE>www.smallco.com</CODE> and
50cb7e2b30597f481fee57bac945190f06ebcc58jorton<CODE>www.baygroup.org</CODE> respectively. These hostnames would both
50cb7e2b30597f481fee57bac945190f06ebcc58jortoncorrespond to the service provider's machine (www.serve.com). Thus
50cb7e2b30597f481fee57bac945190f06ebcc58jortonsmallco's home page would now have the URL
50cb7e2b30597f481fee57bac945190f06ebcc58jorton<BLOCKQUOTE>
af84459fbf938e508fd10b01cb8d699c79083813takashi</BLOCKQUOTE>
af84459fbf938e508fd10b01cb8d699c79083813takashiand baygroup's home page would would have the URL
af84459fbf938e508fd10b01cb8d699c79083813takashi<BLOCKQUOTE>
c04f76acce77126cf88b09350e56ea8c6b4a064enilgun</BLOCKQUOTE>
c04f76acce77126cf88b09350e56ea8c6b4a064enilgunDue to limitations in the HTTP/1.0 protocol, the web server <STRONG>must have a
c04f76acce77126cf88b09350e56ea8c6b4a064enilgundifferent IP address for each virtual host</STRONG>. This can be achieved
c04f76acce77126cf88b09350e56ea8c6b4a064enilgunby the machine having several physical network connections, or by use
c04f76acce77126cf88b09350e56ea8c6b4a064enilgunof a <A HREF="misc/vif-info.html">virtual interface</A> on some operating systems.
c04f76acce77126cf88b09350e56ea8c6b4a064enilgunThere are two ways of configuring apache to support multiple hosts.
af84459fbf938e508fd10b01cb8d699c79083813takashiEither by running a separate httpd daemon for each hostname, or by running a
af84459fbf938e508fd10b01cb8d699c79083813takashisingle daemon which supports all the virtual hosts.
af84459fbf938e508fd10b01cb8d699c79083813takashiUse multiple daemons when:
af84459fbf938e508fd10b01cb8d699c79083813takashi<LI>The different virtual hosts need very different httpd configurations, such
af84459fbf938e508fd10b01cb8d699c79083813takashi as different values for: <A HREF="mod/core.html#servertype">ServerType</A>,
af84459fbf938e508fd10b01cb8d699c79083813takashi <A HREF="mod/mod_mime.html#typesconfig">TypesConfig</A> or
af84459fbf938e508fd10b01cb8d699c79083813takashi<LI>The machine does not process a very high request rate.
af84459fbf938e508fd10b01cb8d699c79083813takashiUse a single daemon when:
af84459fbf938e508fd10b01cb8d699c79083813takashi<LI>Sharing of the httpd configuration between virtual hosts is acceptable.
af84459fbf938e508fd10b01cb8d699c79083813takashi<LI>The machine services a large number of requests, and so the performance
af84459fbf938e508fd10b01cb8d699c79083813takashi loss in running separate daemons may be significant.
af84459fbf938e508fd10b01cb8d699c79083813takashiCreate a separate httpd installation for each virtual host.
af84459fbf938e508fd10b01cb8d699c79083813takashiFor each installation, use the
d0828c8a321dc5e9ea60550f052294669c08cf93jim<A HREF="mod/core.html#bindaddress">BindAddress</A> directive in the configuration
af84459fbf938e508fd10b01cb8d699c79083813takashifile to select which IP address (or virtual host) that daemon services.
af84459fbf938e508fd10b01cb8d699c79083813takashi<BLOCKQUOTE><CODE>BindAddress www.smallco.com</CODE></BLOCKQUOTE>
af84459fbf938e508fd10b01cb8d699c79083813takashiThis hostname can also be given as an IP address.
cd6c8de3bedcc401ee230159b0439fa20f44488etakashiFor this case, a single httpd will service requests for all the virtual hosts.
d0828c8a321dc5e9ea60550f052294669c08cf93jimThe <A HREF="mod/core.html#virtualhost">VirtualHost</A> directive in the
d0828c8a321dc5e9ea60550f052294669c08cf93jim configuration file is used to set the values of
c04f76acce77126cf88b09350e56ea8c6b4a064enilgun<A HREF="mod/core.html#documentroot">DocumentRoot</A>,
c04f76acce77126cf88b09350e56ea8c6b4a064enilgun<A HREF="mod/mod_log_config.html#transferlog">TransferLog</A> configuration
c04f76acce77126cf88b09350e56ea8c6b4a064enilgundirectives to different values for each virtual host.
c04f76acce77126cf88b09350e56ea8c6b4a064enilgunServerAdmin webmaster@mail.smallco.com<BR>
af84459fbf938e508fd10b01cb8d699c79083813takashi</VirtualHost><BR>
af84459fbf938e508fd10b01cb8d699c79083813takashiServerAdmin webmaster@mail.baygroup.org<BR>
af84459fbf938e508fd10b01cb8d699c79083813takashi</VirtualHost><BR>
<!--#include virtual="footer.html" -->