Virtual Hosts
On site.twocopy (see Section 4.3, later in this chapter) we run two different versions of Apache, each serving a different host. As we have said, you might want to do this to optimize the two versions in different ways. However, it is more common to run a number of virtual Apache servers that steer incoming requests on different URLs (usually with the same IP address) to different sets of documents. These might well be home pages for members of your organization or your clients.
In the first edition of this book, we showed how to do this for
Apache 1.2 and HTTP 1.0. The result was rather clumsy, with a main
host and a virtual host, but it coped with HTTP 1.0 clients. However,
the setup can now be done much more neatly with the
NameVirtualHost
directive. The possible combinations
of IP-based and name-based hosts can become quite complex. A full
explanation with examples and the underlying theology can be found at
http://www.apache.org/docs/vhosts, but
several of the possible permutations are unlikely to be very useful
in practice.
Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.