ip-based.xml revision 49038652341bbe660a629c860507622583f8fdf0
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<?xml version='1.0' encoding='UTF-8' ?>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<!DOCTYPE manualpage SYSTEM "/style/manualpage.dtd">
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<manualpage>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<relativepath href=".."/>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <title>Apache IP-based Virtual Host Support</title>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<seealso>
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<a href="name-based.html">Name-based Virtual Hosts Support</a>
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen</seealso>
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<section id="requirements"><title>System requirements</title>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>As the term <cite>IP-based</cite> indicates, the server
d229f940abfb2490dee17979e9a5ff31b7012eb5rbowen <strong>must have a different IP address for each IP-based
3f08db06526d6901aa08c110b5bc7dde6bc39905nd virtual host</strong>. This can be achieved by the machine
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd having several physical network connections, or by use of
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd virtual interfaces which are supported by most modern operating
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd systems (see system documentation for details, these are
3f08db06526d6901aa08c110b5bc7dde6bc39905nd frequently called "ip aliases", and the "ifconfig" command is
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd most commonly used to set them up).</p>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd
af84459fbf938e508fd10b01cb8d699c79083813takashi</section>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd
f3ec420152ca921e4c1ce77782f51b53f659018dnd<section id="howto"><title>How to set up Apache</title>
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>There are two ways of configuring apache to support multiple
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem hosts. Either by running a separate httpd daemon for each
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem hostname, or by running a single daemon which supports all the
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd virtual hosts.</p>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>Use multiple daemons when:</p>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <ul>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <li>There are security partitioning issues, such as company1
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd does not want anyone at company2 to be able to read their
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh data except via the web. In this case you would need two
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd daemons, each running with different <directive
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd module="mpm_common">User</directive>, <directive
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd module="mpm_common">Group</directive>, <directive
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd module="mpm_common">Listen</directive>, and <directive
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd module="core">ServerRoot</directive> settings.</li>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <li>You can afford the memory and <a
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd href="/misc/descriptors.html">file descriptor
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd requirements</a> of listening to every IP alias on the
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd machine. It's only possible to <directive
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd module="mpm_common">Listen</directive> to the "wildcard"
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd address, or to specific addresses. So if you have a need to
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd listen to a specific address for whatever reason, then you
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd will need to listen to all specific addresses. (Although one
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd httpd could listen to N-1 of the addresses, and another could
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd listen to the remaining address.)</li>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </ul>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>Use a single daemon when:</p>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <ul>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <li>Sharing of the httpd configuration between virtual hosts
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd is acceptable.</li>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <li>The machine services a large number of requests, and so
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd the performance loss in running separate daemons may be
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd significant.</li>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </ul>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd</section>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<section id="multiple"><title>Setting up multiple daemons</title>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>Create a separate httpd installation for each virtual host. For
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd each installation, use the <directive
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd module="mpm_common">Listen</directive> directive in the
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd configuration file to select which IP address (or virtual host)
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd that daemon services. e.g.</p>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
71fccc298df6a1540d408151a26aa22beed55d0bnd <example>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd Listen www.smallco.com:80
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </example>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>It is recommended that you use an IP address instead of a
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd hostname (see <a href="/dns-caveats.html">DNS caveats</a>).</p>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd</section>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<section id="single"><title>Setting up a single daemon
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd with virtual hosts</title>
71fccc298df6a1540d408151a26aa22beed55d0bnd
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>For this case, a single httpd will service requests for the
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd main server and all the virtual hosts. The <directive
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd module="core">VirtualHost</directive> directive
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd in the configuration file is used to set the values of <directive
af84459fbf938e508fd10b01cb8d699c79083813takashi module="core">ServerAdmin</directive>, <directive
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd module="core">ServerName</directive>, <directive
f3ec420152ca921e4c1ce77782f51b53f659018dnd module="core">DocumentRoot</directive>, <directive
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung module="core">ErrorLog</directive> and <directive
727872d18412fc021f03969b8641810d8896820bhumbedooh module="mod_log_config">TransferLog</directive>
0d0ba3a410038e179b695446bb149cce6264e0abnd or <directive module="mod_log_config">CustomLog</directive>
727872d18412fc021f03969b8641810d8896820bhumbedooh configuration directives to different values for each virtual
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh host. e.g.</p>
0d0ba3a410038e179b695446bb149cce6264e0abnd
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh <example>
727872d18412fc021f03969b8641810d8896820bhumbedooh &lt;VirtualHost www.smallco.com&gt;<br />
0d0ba3a410038e179b695446bb149cce6264e0abnd ServerAdmin webmaster@mail.smallco.com<br />
0d0ba3a410038e179b695446bb149cce6264e0abnd DocumentRoot /groups/smallco/www<br />
0d0ba3a410038e179b695446bb149cce6264e0abnd ServerName www.smallco.com<br />
727872d18412fc021f03969b8641810d8896820bhumbedooh ErrorLog /groups/smallco/logs/error_log<br />
0d0ba3a410038e179b695446bb149cce6264e0abnd TransferLog /groups/smallco/logs/access_log<br />
0d0ba3a410038e179b695446bb149cce6264e0abnd &lt;/VirtualHost&gt;<br />
0d0ba3a410038e179b695446bb149cce6264e0abnd <br />
727872d18412fc021f03969b8641810d8896820bhumbedooh &lt;VirtualHost www.baygroup.org&gt;<br />
0d0ba3a410038e179b695446bb149cce6264e0abnd ServerAdmin webmaster@mail.baygroup.org<br />
0d0ba3a410038e179b695446bb149cce6264e0abnd DocumentRoot /groups/baygroup/www<br />
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh ServerName www.baygroup.org<br />
5effc8b39fae5cd169d17f342bfc265705840014rbowen ErrorLog /groups/baygroup/logs/error_log<br />
d229f940abfb2490dee17979e9a5ff31b7012eb5rbowen TransferLog /groups/baygroup/logs/access_log<br />
0d0ba3a410038e179b695446bb149cce6264e0abnd &lt;/VirtualHost&gt;
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd </example>
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd <p>It is recommended that you use an IP address instead of a
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd 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>