1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8 <title>Apache IP-based Virtual Host Support - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
13 <body id="manual-page"><div id="page-header">
14 <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>
15 <p class="apache">Apache HTTP Server Version 2.0</p>
16 <img alt="" src="../images/feather.gif" /></div>
17 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
19 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.0</a> > <a href="./">Virtual Hosts</a></div><div id="page-content"><div id="preamble"><h1>Apache IP-based Virtual Host Support</h1>
21 <p><span>Available Languages: </span><a href="../en/vhosts/ip-based.html" title="English"> en </a> |
22 <a href="../ko/vhosts/ip-based.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
23 <a href="../tr/vhosts/ip-based.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
26 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#requirements">System requirements</a></li>
27 <li><img alt="" src="../images/down.gif" /> <a href="#howto">How to set up Apache</a></li>
28 <li><img alt="" src="../images/down.gif" /> <a href="#multiple">Setting up multiple daemons</a></li>
29 <li><img alt="" src="../images/down.gif" /> <a href="#single">Setting up a single daemon
30 with virtual hosts</a></li>
31 </ul><h3>See also</h3><ul class="seealso"><li>
32 <a href="name-based.html">Name-based Virtual Hosts Support</a>
34 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
36 <h2><a name="requirements" id="requirements">System requirements</a></h2>
38 <p>As the term <cite>IP-based</cite> indicates, the server
39 <strong>must have a different IP address for each IP-based
40 virtual host</strong>. This can be achieved by the machine
41 having several physical network connections, or by use of
42 virtual interfaces which are supported by most modern operating
43 systems (see system documentation for details, these are
44 frequently called "ip aliases", and the "ifconfig" command is
45 most commonly used to set them up).</p>
47 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
49 <h2><a name="howto" id="howto">How to set up Apache</a></h2>
51 <p>There are two ways of configuring apache to support multiple
52 hosts. Either by running a separate <code class="program"><a href="../programs/httpd.html">httpd</a></code> daemon for
53 each hostname, or by running a single daemon which supports all the
56 <p>Use multiple daemons when:</p>
59 <li>There are security partitioning issues, such as company1
60 does not want anyone at company2 to be able to read their
61 data except via the web. In this case you would need two
62 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>
64 <li>You can afford the memory and <a href="../misc/descriptors.html">file descriptor
65 requirements</a> of listening to every IP alias on the
66 machine. It's only possible to <code class="directive"><a href="../mod/mpm_common.html#listen">Listen</a></code> to the "wildcard"
67 address, or to specific addresses. So if you have a need to
68 listen to a specific address for whatever reason, then you
69 will need to listen to all specific addresses. (Although one
70 <code class="program"><a href="../programs/httpd.html">httpd</a></code> could listen to N-1 of the addresses, and another could
71 listen to the remaining address.)</li>
74 <p>Use a single daemon when:</p>
77 <li>Sharing of the httpd configuration between virtual hosts
80 <li>The machine services a large number of requests, and so
81 the performance loss in running separate daemons may be
85 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
87 <h2><a name="multiple" id="multiple">Setting up multiple daemons</a></h2>
89 <p>Create a separate <code class="program"><a href="../programs/httpd.html">httpd</a></code> installation for each
90 virtual host. For each installation, use the <code class="directive"><a href="../mod/mpm_common.html#listen">Listen</a></code> directive in the
91 configuration file to select which IP address (or virtual host)
92 that daemon services. e.g.</p>
94 <div class="example"><p><code>
95 Listen www.smallco.com:80
98 <p>It is recommended that you use an IP address instead of a
99 hostname (see <a href="../dns-caveats.html">DNS caveats</a>).</p>
101 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
102 <div class="section">
103 <h2><a name="single" id="single">Setting up a single daemon
104 with virtual hosts</a></h2>
106 <p>For this case, a single httpd will service requests for the
107 main server and all the virtual hosts. The <code class="directive"><a href="../mod/core.html#virtualhost">VirtualHost</a></code> directive
108 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>
109 or <code class="directive"><a href="../mod/mod_log_config.html#customlog">CustomLog</a></code>
110 configuration directives to different values for each virtual
113 <div class="example"><p><code>
114 <VirtualHost www.smallco.com><br />
115 ServerAdmin webmaster@mail.smallco.com<br />
116 DocumentRoot /groups/smallco/www<br />
117 ServerName www.smallco.com<br />
118 ErrorLog /groups/smallco/logs/error_log<br />
119 TransferLog /groups/smallco/logs/access_log<br />
120 </VirtualHost><br />
122 <VirtualHost www.baygroup.org><br />
123 ServerAdmin webmaster@mail.baygroup.org<br />
124 DocumentRoot /groups/baygroup/www<br />
125 ServerName www.baygroup.org<br />
126 ErrorLog /groups/baygroup/logs/error_log<br />
127 TransferLog /groups/baygroup/logs/access_log<br />
131 <p>It is recommended that you use an IP address instead of a
132 hostname (see <a href="../dns-caveats.html">DNS caveats</a>).</p>
134 <p>Almost <strong>any</strong> configuration directive can be
135 put in the VirtualHost directive, with the exception of
136 directives that control process creation and a few other
137 directives. To find out if a directive can be used in the
138 VirtualHost directive, check the <a href="../mod/directive-dict.html#Context">Context</a> using the
139 <a href="../mod/directives.html">directive index</a>.</p>
141 <p><code class="directive"><a href="../mod/mod_suexec.html#suexecusergroup">SuexecUserGroup</a></code>
143 VirtualHost directive if the <a href="../suexec.html">suEXEC
144 wrapper</a> is used.</p>
146 <p><em>SECURITY:</em> When specifying where to write log files,
147 be aware of some security risks which are present if anyone
148 other than the user that starts Apache has write access to the
149 directory where they are written. See the <a href="../misc/security_tips.html">security tips</a> document
153 <div class="bottomlang">
154 <p><span>Available Languages: </span><a href="../en/vhosts/ip-based.html" title="English"> en </a> |
155 <a href="../ko/vhosts/ip-based.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
156 <a href="../tr/vhosts/ip-based.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
157 </div><div id="footer">
158 <p class="apache">Copyright 2009 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
159 <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>