ip-based.html revision dd2cbf08558860773e4afc8d4f8cce3d85d77f58
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<title>Apache IP-based Virtual Host Support</title>
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan BGCOLOR="#FFFFFF"
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan TEXT="#000000"
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan LINK="#0000FF"
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan VLINK="#000080"
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan ALINK="#FF0000"
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<!--#include virtual="header.html" -->
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<h1 ALIGN="CENTER">Apache IP-based Virtual Host Support</h1>
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<a href="name-based.html">Name-based Virtual Hosts Support</a>
305373bfa854723d80c740a2ff9d277d0f34082aHarry PanAs the term <cite>IP-based</cite> indicates, the server <strong>must have a
b4a94e1e9bfb77dcba635f9e3cfd4fd4276b64ccLubos Koscodifferent IP address for each IP-based virtual host</strong>.
b4a94e1e9bfb77dcba635f9e3cfd4fd4276b64ccLubos KoscoThis can be achieved by the machine having several physical network connections,
305373bfa854723d80c740a2ff9d277d0f34082aHarry Panor by use of virtual interfaces which are supported by most modern
b4a94e1e9bfb77dcba635f9e3cfd4fd4276b64ccLubos Koscooperating systems (see system documentation for details, these are
305373bfa854723d80c740a2ff9d277d0f34082aHarry Panfrequently called "ip aliases", and the "ifconfig" command
b4a94e1e9bfb77dcba635f9e3cfd4fd4276b64ccLubos Koscois most commonly used to set them up).
305373bfa854723d80c740a2ff9d277d0f34082aHarry PanThere are two ways of configuring apache to support multiple hosts.
305373bfa854723d80c740a2ff9d277d0f34082aHarry PanEither by running a separate httpd daemon for each hostname, or by running a
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pansingle daemon which supports all the virtual hosts.
305373bfa854723d80c740a2ff9d277d0f34082aHarry PanUse multiple daemons when:
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<li>The different virtual hosts need very different httpd configurations, such
b4a94e1e9bfb77dcba635f9e3cfd4fd4276b64ccLubos Kosco as different values for: <A HREF="/mod/core.html#servertype">ServerType</A>,
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan <A HREF="/mod/mod_mime.html#typesconfig">TypesConfig</A> or
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan <A HREF="/mod/core.html#serverroot">ServerRoot</A>.
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<li>The machine does not process a very high request rate.
305373bfa854723d80c740a2ff9d277d0f34082aHarry PanUse a single daemon when:
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<li>Sharing of the httpd configuration between virtual hosts is acceptable.
98bcd7b17c979c7394ffc18d7c052a0b5602208eJHKST<li>The machine services a large number of requests, and so the performance
98bcd7b17c979c7394ffc18d7c052a0b5602208eJHKST loss in running separate daemons may be significant.
305373bfa854723d80c740a2ff9d277d0f34082aHarry PanCreate a separate httpd installation for each virtual host.
305373bfa854723d80c740a2ff9d277d0f34082aHarry PanFor each installation, use the
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<A HREF="/mod/core.html#listen">Listen</A> directive in the configuration
305373bfa854723d80c740a2ff9d277d0f34082aHarry Panfile to select which IP address (or virtual host) that daemon services.
305373bfa854723d80c740a2ff9d277d0f34082aHarry PanIt is recommended that you use an IP address instead of a hostname
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<h2>Setting up a single daemon with virtual hosts</h2>
305373bfa854723d80c740a2ff9d277d0f34082aHarry PanFor this case, a single httpd will service requests for the main server
305373bfa854723d80c740a2ff9d277d0f34082aHarry Panand all the virtual hosts.
305373bfa854723d80c740a2ff9d277d0f34082aHarry PanThe <A HREF="/mod/core.html#virtualhost">VirtualHost</A> directive in the
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan configuration file is used to set the values of
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<A HREF="/mod/core.html#serveradmin">ServerAdmin</A>,
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<A HREF="/mod/core.html#servername">ServerName</A>,
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<A HREF="/mod/core.html#documentroot">DocumentRoot</A>,
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<A HREF="/mod/mod_log_config.html#transferlog">TransferLog</A> or
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan<A HREF="/mod/mod_log_config.html#customlog">CustomLog</A>
305373bfa854723d80c740a2ff9d277d0f34082aHarry Panconfiguration directives to different values for each virtual host.
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan <VirtualHost www.smallco.com>
98bcd7b17c979c7394ffc18d7c052a0b5602208eJHKST ServerAdmin webmaster@mail.smallco.com
eb1776903fd1f998009e97470a65fba8a499a0d9Lubos Kosco </VirtualHost>
eb1776903fd1f998009e97470a65fba8a499a0d9Lubos Kosco <VirtualHost www.baygroup.org>
305373bfa854723d80c740a2ff9d277d0f34082aHarry Pan ServerAdmin webmaster@mail.baygroup.org
ServerName www.baygroup.org
<!--#include virtual="footer.html" -->