ip-based.xml revision fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2
883N/A<?xml version='1.0' encoding='UTF-8' ?>
883N/A<!DOCTYPE manualpage SYSTEM "/style/manualpage.dtd">
883N/A<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
883N/A
883N/A<manualpage>
883N/A<relativepath href=".."/>
883N/A
883N/A <title>Apache IP-based Virtual Host Support</title>
883N/A
883N/A<seealso>
883N/A<a href="name-based.html">Name-based Virtual Hosts Support</a>
883N/A</seealso>
883N/A
883N/A<section id="requirements"><title>System requirements</title>
883N/A
883N/A <p>As the term <cite>IP-based</cite> indicates, the server
883N/A <strong>must have a different IP address for each IP-based
883N/A virtual host</strong>. This can be achieved by the machine
883N/A having several physical network connections, or by use of
883N/A virtual interfaces which are supported by most modern operating
883N/A systems (see system documentation for details, these are
883N/A frequently called "ip aliases", and the "ifconfig" command is
3734N/A most commonly used to set them up).</p>
883N/A
883N/A</section>
3734N/A
3734N/A<section id="howto"><title>How to set up Apache</title>
883N/A
3734N/A <p>There are two ways of configuring apache to support multiple
3734N/A hosts. Either by running a separate httpd daemon for each
883N/A hostname, or by running a single daemon which supports all the
3734N/A virtual hosts.</p>
901N/A
883N/A <p>Use multiple daemons when:</p>
901N/A
883N/A <ul>
3734N/A <li>There are security partitioning issues, such as company1
3734N/A does not want anyone at company2 to be able to read their
3734N/A data except via the web. In this case you would need two
3734N/A daemons, each running with different <directive
3734N/A module="mpm_common">User</directive>, <directive
module="mpm_common">Group</directive>, <directive
module="mpm_common">Listen</directive>, and <directive
module="core">ServerRoot</directive> settings.</li>
<li>You can afford the memory and <a
href="/misc/descriptors.html">file descriptor
requirements</a> of listening to every IP alias on the
machine. It's only possible to <directive
module="mpm_common">Listen</directive> to the "wildcard"
address, or to specific addresses. So if you have a need to
listen to a specific address for whatever reason, then you
will need to listen to all specific addresses. (Although one
httpd could listen to N-1 of the addresses, and another could
listen to the remaining address.)</li>
</ul>
<p>Use a single daemon when:</p>
<ul>
<li>Sharing of the httpd configuration between virtual hosts
is acceptable.</li>
<li>The machine services a large number of requests, and so
the performance loss in running separate daemons may be
significant.</li>
</ul>
</section>
<section id="multiple"><title>Setting up multiple daemons</title>
<p>Create a separate httpd installation for each virtual host. For
each installation, use the <directive
module="mpm_common">Listen</directive> directive in the
configuration file to select which IP address (or virtual host)
that daemon services. e.g.</p>
<example>
<pre>
Listen www.smallco.com:80
</pre>
</example>
<p>It is recommended that you use an IP address instead of a
hostname (see <a href="/dns-caveats.html">DNS caveats</a>).</p>
</section>
<section id="single"><title>Setting up a single daemon
with virtual hosts</title>
<p>For this case, a single httpd will service requests for the
main server and all the virtual hosts. The <directive
module="core">VirtualHost</directive> directive
in the configuration file is used to set the values of <directive
module="core">ServerAdmin</directive>, <directive
module="core">ServerName</directive>, <directive
module="core">DocumentRoot</directive>, <directive
module="core">ErrorLog</directive> and <directive
module="mod_log_config">TransferLog</directive>
or <directive module="mod_log_config">CustomLog</directive>
configuration directives to different values for each virtual
host. e.g.</p>
<example>
<pre>
&lt;VirtualHost www.smallco.com&gt;
ServerAdmin webmaster@mail.smallco.com
DocumentRoot /groups/smallco/www
ServerName www.smallco.com
ErrorLog /groups/smallco/logs/error_log
TransferLog /groups/smallco/logs/access_log
&lt;/VirtualHost&gt;
&lt;VirtualHost www.baygroup.org&gt;
ServerAdmin webmaster@mail.baygroup.org
DocumentRoot /groups/baygroup/www
ServerName www.baygroup.org
ErrorLog /groups/baygroup/logs/error_log
TransferLog /groups/baygroup/logs/access_log
&lt;/VirtualHost&gt;
</pre>
</example>
<p>It is recommended that you use an IP address instead of a
hostname (see <a href="/dns-caveats.html">DNS caveats</a>).</p>
<p>Almost <strong>any</strong> configuration directive can be
put in the VirtualHost directive, with the exception of
directives that control process creation and a few other
directives. To find out if a directive can be used in the
VirtualHost directive, check the <a
href="/mod/directive-dict.html#Context">Context</a> using the
<a href="/mod/directives.html">directive index</a>.</p>
<p><directive module="mpm_common">User</directive> and <directive
module="mpm_common">Group</directive> may be used inside a
VirtualHost directive if the <a href="/suexec.html">suEXEC
wrapper</a> is used.</p>
<p><em>SECURITY:</em> When specifying where to write log files,
be aware of some security risks which are present if anyone
other than the user that starts Apache has write access to the
directory where they are written. See the <a
href="/misc/security_tips.html">security tips</a> document
for details.</p>
</section>
</manualpage>