From: Daniel Gruno The term Virtual Host refers to the practice of
running more than one web site (such as
- Below is a list of documentation pages which explain all
- details of virtual host support in Apache version 1.3 and
- later.www.company1.com
and www.company2.com
)
+ company1.example.com
and company2.example.com
)
on a single machine. Virtual hosts can be "IP-based", meaning that you have a
different IP address for every web site, or "host-based or non-IP virtual hosts.
IP-based virtual hosting is a method to apply different directives +based on the IP address and port a request is received on. Most commonly, +this is used to serve different websites on different ports or interfaces.
+ +In many cases, name-based +virtual hosts are more convenient, because they allow +many virtual hosts to share a single address/port. +See Name-based vs. IP-based +Virtual Hosts to help you decide.
+As the term IP-based indicates, the server - must have a different IP address for each IP-based + must have a different IP address/port combination for each IP-based virtual host. This can be achieved by the machine having several physical network connections, or by use of virtual interfaces which are supported by most modern operating systems (see system documentation for details, these are frequently called "ip aliases", and the "ifconfig" command is - most commonly used to set them up).
+ most commonly used to set them up), and/or using multiple + port numbers. + +In the terminology of Apache HTTP Server, using a single IP address + but multiple TCP ports, is also IP-based virtual hosting.
For this case, a single
</VirtualHost>
-
+
<VirtualHost 192.168.0.2:80>
ServerAdmin webmaster@baygroup.example.org
DocumentRoot /groups/baygroup/www
ServerName baygroup.example.com
ErrorLog /groups/baygroup/logs/error_log
TransferLog /groups/baygroup/logs/access_log
- </VirtualHost>
-
+</VirtualHost>
+
It is recommended that you use an IP address instead of a - hostname (see DNS caveats).
+ hostname in the <VirtualHost> directive + (see DNS caveats). + +Specific IP addresses or ports have precedence over their wildcard + equivalents, and any virtual host that matches has precedence over + the servers base configuration.
Almost any configuration directive can be put in the VirtualHost directive, with the exception of