IP-Based Virtual Hosts
This alternative virtual host configuration requires the setup of multiple IPs for a ma-
chine. One instance of Apache hosts several domains, each of which is assigned a dif-
ferent IP.
The physical server must have one IP address for each IP-based virtual host. If the
machine does not have multiple network cards, virtual network interfaces (IP aliasing)
can also be used.
The following example shows Apache running on a machine with the IP
192.168.3.100, hosting two domains on the additional IPs 192.168.3.101 and
192.168.3.102. A separate VirtualHost block is needed for every virtual
server.
Example 40.3 IP-Based VirtualHost Directives
<VirtualHost 192.168.3.101>
...
</VirtualHost>
<VirtualHost 192.168.3.102>
...
</VirtualHost>
Here, VirtualHost directives are only specified for interfaces other than
192.168.3.100. When a Listen directive is also configured for
192.168.3.100, a separate IP-based virtual host must be created to answer HTTP
requests to that interface—otherwise the directives found in the default server configu-
ration (/etc/apache2/default-server.conf) are applied.
Basic Virtual Host Configuration
At least the following directives should be present in each virtual host configuration in
order to set up a virtual host. See /etc/apache2/vhosts.d/vhost.template
for more options.
ServerName
The fully qualified domain name under which the host should be addressed.
The Apache HTTP Server
749