1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
4<html xmlns="http://www.w3.org/1999/xhtml">
5  <head>
6    <meta name="generator" content="HTML Tidy, see www.w3.org" />
7
8    <title>Apache IP-based Virtual Host Support</title>
9  </head>
10  <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
11
12  <body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
13  vlink="#000080" alink="#FF0000">
14        <div align="CENTER">
15      <img src="../images/sub.gif" alt="[APACHE DOCUMENTATION]" />
16
17      <h3>Apache HTTP Server Version 1.3</h3>
18    </div>
19
20
21    <h1 align="CENTER">Apache IP-based Virtual Host Support</h1>
22    <strong>See also:</strong> <a href="name-based.html">Name-based
23    Virtual Hosts Support</a>
24    <hr />
25
26    <h2>System requirements</h2>
27    As the term <cite>IP-based</cite> indicates, the server
28    <strong>must have a different IP address for each IP-based
29    virtual host</strong>. This can be achieved by the machine
30    having several physical network connections, or by use of
31    virtual interfaces which are supported by most modern operating
32    systems (see system documentation for details, these are
33    frequently called "ip aliases", and the "ifconfig" command is
34    most commonly used to set them up).
35
36    <h2>How to set up Apache</h2>
37    There are two ways of configuring apache to support multiple
38    hosts. Either by running a separate httpd daemon for each
39    hostname, or by running a single daemon which supports all the
40    virtual hosts.
41
42    <p>Use multiple daemons when:</p>
43
44    <ul>
45      <li>There are security partitioning issues, such as company1
46      does not want anyone at company2 to be able to read their
47      data except via the web. In this case you would need two
48      daemons, each running with different <a
49      href="../mod/core.html#user">User</a>, <a
50      href="../mod/core.html#group">Group</a>, <a
51      href="../mod/core.html#listen">Listen</a>, and <a
52      href="../mod/core.html#serverroot">ServerRoot</a>
53      settings.</li>
54
55      <li>You can afford the memory and <a
56      href="../misc/descriptors.html">file descriptor
57      requirements</a> of listening to every IP alias on the
58      machine. It's only possible to <a
59      href="../mod/core.html#listen">Listen</a> to the "wildcard"
60      address, or to specific addresses. So if you have a need to
61      listen to a specific address for whatever reason, then you
62      will need to listen to all specific addresses. (Although one
63      httpd could listen to N-1 of the addresses, and another could
64      listen to the remaining address.)</li>
65    </ul>
66    Use a single daemon when:
67
68    <ul>
69      <li>Sharing of the httpd configuration between virtual hosts
70      is acceptable.</li>
71
72      <li>The machine services a large number of requests, and so
73      the performance loss in running separate daemons may be
74      significant.</li>
75    </ul>
76
77    <h2>Setting up multiple daemons</h2>
78    Create a separate httpd installation for each virtual host. For
79    each installation, use the <a
80    href="../mod/core.html#listen">Listen</a> directive in the
81    configuration file to select which IP address (or virtual host)
82    that daemon services. e.g.
83<pre>
84    Listen www.smallco.com:80
85</pre>
86    It is recommended that you use an IP address instead of a
87    hostname (see <a href="../dns-caveats.html">DNS caveats</a>).
88
89    <h2>Setting up a single daemon with virtual hosts</h2>
90    For this case, a single httpd will service requests for the
91    main server and all the virtual hosts. The <a
92    href="../mod/core.html#virtualhost">VirtualHost</a> directive
93    in the configuration file is used to set the values of <a
94    href="../mod/core.html#serveradmin">ServerAdmin</a>, <a
95    href="../mod/core.html#servername">ServerName</a>, <a
96    href="../mod/core.html#documentroot">DocumentRoot</a>, <a
97    href="../mod/core.html#errorlog">ErrorLog</a> and <a
98    href="../mod/mod_log_config.html#transferlog">TransferLog</a>
99    or <a href="../mod/mod_log_config.html#customlog">CustomLog</a>
100    configuration directives to different values for each virtual
101    host. e.g.
102<pre>
103    &lt;VirtualHost www.smallco.com&gt;
104    ServerAdmin webmaster@mail.smallco.com
105    DocumentRoot /groups/smallco/www
106    ServerName www.smallco.com
107    ErrorLog /groups/smallco/logs/error_log
108    TransferLog /groups/smallco/logs/access_log
109    &lt;/VirtualHost&gt;
110
111    &lt;VirtualHost www.baygroup.org&gt;
112    ServerAdmin webmaster@mail.baygroup.org
113    DocumentRoot /groups/baygroup/www
114    ServerName www.baygroup.org
115    ErrorLog /groups/baygroup/logs/error_log
116    TransferLog /groups/baygroup/logs/access_log
117    &lt;/VirtualHost&gt;
118</pre>
119    It is recommended that you use an IP address instead of a
120    hostname (see <a href="../dns-caveats.html">DNS caveats</a>).
121
122    <p>Almost <strong>any</strong> configuration directive can be
123    put in the VirtualHost directive, with the exception of
124    directives that control process creation and a few other
125    directives. To find out if a directive can be used in the
126    VirtualHost directive, check the <a
127    href="../mod/directive-dict.html#Context">Context</a> using the
128    <a href="../mod/directives.html">directive index</a>.</p>
129
130    <p><a href="../mod/core.html#user">User</a> and <a
131    href="../mod/core.html#group">Group</a> may be used inside a
132    VirtualHost directive if the <a href="../suexec.html">suEXEC
133    wrapper</a> is used.</p>
134
135    <p><em>SECURITY:</em> When specifying where to write log files,
136    be aware of some security risks which are present if anyone
137    other than the user that starts Apache has write access to the
138    directory where they are written. See the <a
139    href="../misc/security_tips.html">security tips</a> document
140    for details.</p>
141        <hr />
142
143    <h3 align="CENTER">Apache HTTP Server Version 1.3</h3>
144    <a href="./"><img src="../images/index.gif" alt="Index" /></a>
145    <a href="../"><img src="../images/home.gif" alt="Home" /></a>
146
147  </body>
148</html>
149
150