ip-based.html.en revision b95ae799514ad86a15610ad75808d7065e9847c9
97a9a944b5887e91042b019776c41d5dd74557aferikabele<?xml version="1.0" encoding="ISO-8859-1"?>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
97a9a944b5887e91042b019776c41d5dd74557aferikabele<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive This file is generated from xml source: DO NOT EDIT
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
b686b6a420bde7f78c416b90be11db94cb789979nd -->
b686b6a420bde7f78c416b90be11db94cb789979nd<title>Apache IP-based Virtual Host Support - Apache HTTP Server</title>
b686b6a420bde7f78c416b90be11db94cb789979nd<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
b686b6a420bde7f78c416b90be11db94cb789979nd<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
b686b6a420bde7f78c416b90be11db94cb789979nd<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
b686b6a420bde7f78c416b90be11db94cb789979nd<link href="/images/favicon.ico" rel="shortcut icon" /></head>
b686b6a420bde7f78c416b90be11db94cb789979nd<body id="manual-page"><div id="page-header">
b686b6a420bde7f78c416b90be11db94cb789979nd<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
b686b6a420bde7f78c416b90be11db94cb789979nd<p class="apache">Apache HTTP Server Version 2.1</p>
b686b6a420bde7f78c416b90be11db94cb789979nd<img alt="" src="/images/feather.gif" /></div>
b686b6a420bde7f78c416b90be11db94cb789979nd<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
b686b6a420bde7f78c416b90be11db94cb789979nd<div id="path">
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs-project/">Documentation</a> &gt; <a href="../">Version 2.1</a> &gt; <a href="./">Virtual Hosts</a></div><div id="page-content"><div id="preamble"><h1>Apache IP-based Virtual Host Support</h1>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<div class="toplang">
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<p><span>Available Languages: </span><a href="/en/vhosts/ip-based.html" title="English">&nbsp;en&nbsp;</a> |
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<a href="/ja/vhosts/ip-based.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
b05ab3ff5ab54aa22610b13d56eaba6ddfc3db60nd<a href="/ko/vhosts/ip-based.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd</div>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd</div>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#requirements">System requirements</a></li>
b686b6a420bde7f78c416b90be11db94cb789979nd<li><img alt="" src="/images/down.gif" /> <a href="#howto">How to set up Apache</a></li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<li><img alt="" src="/images/down.gif" /> <a href="#multiple">Setting up multiple daemons</a></li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<li><img alt="" src="/images/down.gif" /> <a href="#single">Setting up a single daemon
06ba4a61654b3763ad65f52283832ebf058fdf1cslive with virtual hosts</a></li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</ul><h3>See also</h3><ul class="seealso"><li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<a href="name-based.html">Name-based Virtual Hosts Support</a>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</li></ul></div>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd<div class="section">
5b10fd3977e6dfff19afe770e612e276962f7950nd<h2><a name="requirements" id="requirements">System requirements</a></h2>
5b10fd3977e6dfff19afe770e612e276962f7950nd
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <p>As the term <cite>IP-based</cite> indicates, the server
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <strong>must have a different IP address for each IP-based
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd virtual host</strong>. This can be achieved by the machine
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd having several physical network connections, or by use of
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd virtual interfaces which are supported by most modern operating
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd systems (see system documentation for details, these are
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd frequently called "ip aliases", and the "ifconfig" command is
5b10fd3977e6dfff19afe770e612e276962f7950nd most commonly used to set them up).</p>
5b10fd3977e6dfff19afe770e612e276962f7950nd
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd<div class="section">
2aff288113d772cedca6add888eb643afffe9fb1nd<h2><a name="howto" id="howto">How to set up Apache</a></h2>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd
2aff288113d772cedca6add888eb643afffe9fb1nd <p>There are two ways of configuring apache to support multiple
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd hosts. Either by running a separate <code class="program"><a href="/programs/httpd.html">httpd</a></code> daemon for
7fa75a06a4fee19e995c069ee00310455d1452e1pquerna each hostname, or by running a single daemon which supports all the
7fa75a06a4fee19e995c069ee00310455d1452e1pquerna virtual hosts.</p>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <p>Use multiple daemons when:</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd <ul>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <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
2aff288113d772cedca6add888eb643afffe9fb1nd daemons, each running with different <code class="directive"><a href="/mod/mpm_common.html#user">User</a></code>, <code class="directive"><a href="/mod/mpm_common.html#group">Group</a></code>, <code class="directive"><a href="/mod/mpm_common.html#listen">Listen</a></code>, and <code class="directive"><a href="/mod/core.html#serverroot">ServerRoot</a></code> settings.</li>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <li>You can afford the memory and file descriptor
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd requirements of listening to every IP alias on the
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd machine. It's only possible to <code class="directive"><a href="/mod/mpm_common.html#listen">Listen</a></code> to the "wildcard"
2aff288113d772cedca6add888eb643afffe9fb1nd address, or to specific addresses. So if you have a need to
2aff288113d772cedca6add888eb643afffe9fb1nd listen to a specific address for whatever reason, then you
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd will need to listen to all specific addresses. (Although one
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd <code class="program"><a href="/programs/httpd.html">httpd</a></code> could listen to N-1 of the addresses, and another could
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd listen to the remaining address.)</li>
db99fa79ac42b9cc42b63386eb289aecb0f3cb9cnd </ul>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd
2aff288113d772cedca6add888eb643afffe9fb1nd <p>Use a single daemon when:</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd <ul>
2aff288113d772cedca6add888eb643afffe9fb1nd <li>Sharing of the httpd configuration between virtual hosts
2aff288113d772cedca6add888eb643afffe9fb1nd is acceptable.</li>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd <li>The machine services a large number of requests, and so
2aff288113d772cedca6add888eb643afffe9fb1nd the performance loss in running separate daemons may be
2aff288113d772cedca6add888eb643afffe9fb1nd significant.</li>
2aff288113d772cedca6add888eb643afffe9fb1nd </ul>
2aff288113d772cedca6add888eb643afffe9fb1nd
aa0b2780958e9b1467c9d0153a05738e399811a5nd</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
2aff288113d772cedca6add888eb643afffe9fb1nd<div class="section">
42af92a661a06b3cebc88d585aad75064a309d51nd<h2><a name="multiple" id="multiple">Setting up multiple daemons</a></h2>
42af92a661a06b3cebc88d585aad75064a309d51nd
2aff288113d772cedca6add888eb643afffe9fb1nd <p>Create a separate <code class="program"><a href="/programs/httpd.html">httpd</a></code> installation for each
aa0b2780958e9b1467c9d0153a05738e399811a5nd virtual host. For each installation, use the <code class="directive"><a href="/mod/mpm_common.html#listen">Listen</a></code> directive in the
2aff288113d772cedca6add888eb643afffe9fb1nd configuration file to select which IP address (or virtual host)
2aff288113d772cedca6add888eb643afffe9fb1nd that daemon services. e.g.</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
64c02f1310b7747423957823ee09fb3608430f89nd <div class="example"><p><code>
aa0b2780958e9b1467c9d0153a05738e399811a5nd Listen www.smallco.com:80
2aff288113d772cedca6add888eb643afffe9fb1nd </code></p></div>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd <p>It is recommended that you use an IP address instead of a
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd hostname (see <a href="/dns-caveats.html">DNS caveats</a>).</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
2aff288113d772cedca6add888eb643afffe9fb1nd<div class="section">
2aff288113d772cedca6add888eb643afffe9fb1nd<h2><a name="single" id="single">Setting up a single daemon
2aff288113d772cedca6add888eb643afffe9fb1nd with virtual hosts</a></h2>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd
2aff288113d772cedca6add888eb643afffe9fb1nd <p>For this case, a single <code class="program"><a href="/programs/httpd.html">httpd</a></code> will service
e67fa8d3f161e595dd448fc24a591ee17ae59131nd requests for the main server and all the virtual hosts. The <code class="directive"><a href="/mod/core.html#virtualhost">VirtualHost</a></code> directive
05ede5110427cb9dc071cc671d5aaba5d3b88c79nd in the configuration file is used to set the values of <code class="directive"><a href="/mod/core.html#serveradmin">ServerAdmin</a></code>, <code class="directive"><a href="/mod/core.html#servername">ServerName</a></code>, <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code>, <code class="directive"><a href="/mod/core.html#errorlog">ErrorLog</a></code> and <code class="directive"><a href="/mod/mod_log_config.html#transferlog">TransferLog</a></code>
e8b603fa9ccf7b17b11b42df6d8916fd97c2331dnd or <code class="directive"><a href="/mod/mod_log_config.html#customlog">CustomLog</a></code>
bf94bedcb62d7f0b926f4286069def5ee6b07b60nd configuration directives to different values for each virtual
bf94bedcb62d7f0b926f4286069def5ee6b07b60nd host. e.g.</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd <div class="example"><p><code>
bbcbf978a3074512c627c797fedcb30eeab7b39dslive &lt;VirtualHost www.smallco.com&gt;<br />
ee5db395bc3723609919edfa96af387eea37c491jim ServerAdmin webmaster@mail.smallco.com<br />
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd DocumentRoot /groups/smallco/www<br />
2aff288113d772cedca6add888eb643afffe9fb1nd ServerName www.smallco.com<br />
e55e60efce8a3e2139132c1d6ad9f6f0d2976614nd ErrorLog /groups/smallco/logs/error_log<br />
e55e60efce8a3e2139132c1d6ad9f6f0d2976614nd TransferLog /groups/smallco/logs/access_log<br />
2aff288113d772cedca6add888eb643afffe9fb1nd &lt;/VirtualHost&gt;<br />
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive <br />
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive &lt;VirtualHost www.baygroup.org&gt;<br />
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive ServerAdmin webmaster@mail.baygroup.org<br />
75585bd48fe0f30483dba4762e61edf39ea3e0f6nd DocumentRoot /groups/baygroup/www<br />
75585bd48fe0f30483dba4762e61edf39ea3e0f6nd ServerName www.baygroup.org<br />
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd ErrorLog /groups/baygroup/logs/error_log<br />
03a4ff9ac4c9b8009249010e7c53bb86ff05915and TransferLog /groups/baygroup/logs/access_log<br />
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd &lt;/VirtualHost&gt;
3b58542e01ec69422f3086db5825a12fc77b726end </code></p></div>
a0d937b340692a3578f1d2f2535890c520c4bf0cnd
7d15331eeb5429d7148d13d6fd914a641bf1c000pquerna <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
2aff288113d772cedca6add888eb643afffe9fb1nd <p>Almost <strong>any</strong> configuration directive can be
2aff288113d772cedca6add888eb643afffe9fb1nd put in the VirtualHost directive, with the exception of
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd directives that control process creation and a few other
08842292d2f1550b40ae73e0dafc7641c5955c82nd directives. To find out if a directive can be used in the
2aff288113d772cedca6add888eb643afffe9fb1nd VirtualHost directive, check the <a href="/mod/directive-dict.html#Context">Context</a> using the
d2b809e5d72658bff23819d8b77f20e4939af541nd <a href="/mod/directives.html">directive index</a>.</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd <p><code class="directive"><a href="/mod/mpm_common.html#user">User</a></code> and <code class="directive"><a href="/mod/mpm_common.html#group">Group</a></code> may be used inside a
2aff288113d772cedca6add888eb643afffe9fb1nd 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
2aff288113d772cedca6add888eb643afffe9fb1nd other than the user that starts Apache has write access to the
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd directory where they are written. See the <a href="/misc/security_tips.html">security tips</a> document
c023f60e35022146373e40249f0c8c8d623b6fcfnd for details.</p>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd
a43bfa789f4e52dde53ae8e53fa0427b5c1cf977nd</div></div>
a43bfa789f4e52dde53ae8e53fa0427b5c1cf977nd<div class="bottomlang">
101bf3584c853027d9e51df6edfff5ff70c80238jim<p><span>Available Languages: </span><a href="/en/vhosts/ip-based.html" title="English">&nbsp;en&nbsp;</a> |
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd<a href="/ja/vhosts/ip-based.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd<a href="/ko/vhosts/ip-based.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd</div><div id="footer">
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd<p class="apache">Copyright 1995-2005 The Apache Software Foundation or its licensors, as applicable.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div>
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd</body></html>