Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Chapter 4 4 CHAPTER Virtual Hosts Two Sites and Apache Our business has now expanded, and we have a team of salespeople. They need their own web site--with different prices, gossip about competitors, conspiracies, plots, plans, and so on--that is separate from the customers' web site we have been talk- ing about. There are essentially two ways of doing this: 1. Run a single copy of Apache that maintains two or more web sites as virtual sites. This is the most common method. 2. Run two (or more) copies of Apache, each maintaining a single site. You may want to do this to optimize two versions of Apache in different ways--for instance, one serving images and the other running scripts. Virtual Hosts On site.twocopy (see "Two Copies of Apache," later in this chapter) we run two dif- ferent 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. 86 This is the Title of the Book, eMatter Edition Copyright © 2007 O'Reilly & Associates, Inc. All rights reserved.