Return-Path: Using the new virtual hosts is quite easy, and superficially looks
-like the old method. You simply add to one of the Apache configuration
-files (most likely Using non-IP Virtual Hosts
httpd.conf
or srm.conf
)
-code similar to the following:NameVirtualHost
+directive which specifies an IP address that should be used as a
+target for name-based virtual hosts.
For example, suppose that both www.domain.tld and
+www.otherdomain.tld point at the IP address
+111.22.33.44. Then you simply add to one of the Apache
+configuration files (most likely httpd.conf
or
+srm.conf
) code similar to the following:
NameVirtualHost 111.22.33.44 <VirtualHost 111.22.33.44> ServerName www.domain.tld - DocumentRoot /web/domain + DocumentRoot /www/domain </VirtualHost> --
The notable difference between IP-based and name-based virtual host
-configuration is the
-NameVirtualHost
-directive which specifies an IP address that should be used as a target for
-name-based virtual hosts.
+ <VirtualHost 111.22.33.44>
+ ServerName www.otherdomain.tld
+ DocumentRoot /www/otherdomain
+ </VirtualHost>
+
Of course, any additional directives can (and should) be placed
into the <VirtualHost>
section. To make this work,
-all that is needed is to make sure that the name
-www.domain.tld points to the IP address
-111.22.33.44
Note: When you specify an IP address in a NameVirtualHost
directive then requests to that IP address will only ever be served
-by matching <VirtualHost>s. The "main server" will never
-be served from the specified IP address.
+by matching <VirtualHost>s. The "main server" will
+never be served from the specified IP address.
+If you start to use virtual hosts you should stop to use the "main server"
+as an independent server and rather use it as a place for
+configuration directives that are common for all your virtual hosts.
+In other words, you should add a <VirtualHost> section for
+every server (hostname) you want to maintain on your server.
Additionally, many servers may wish to be accessible by more than one name. For example, the example server might want to be accessible