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