Pro Apache pp 405-455 | Cite as

Hosting More Than One Web Site

  • Peter Wainwright


In many cases you may need to host more than one Web site. Providing a separate server for each site is certainly one solution, but it can be expensive both in terms of cost and in terms of maintenance. Assuming you want to serve multiple sites from a single server, you have four different approaches available to allow Apache to host more than one Web site:
  • User home pages: The simplest approach is to group all sites under one controlling hostname This is most suitable for situations where the administrator wants to give individual users the ability to maintain their own home pages without reconfiguring the server each time a new user is added. Apache supports this model with the UserDir directive. Users may use limited configuration by creating .htaccess files inside their directory.

  • Separate servers: This approach solves the problem by running more than one instance of Apache at the same time. Each Web site is served by a different invocation of Apache configured with a different IP address and port number, all running on the same server. Although as an approach this is a little heavy, it consumes far more memory than a single Apache instance and there’s no sharing of resources, but it helps to increase the security and reliability.

  • IP-based virtual hosting: Instead of serving different IP addresses with different servers, Apache can serve all addresses simultaneously from one configuration using the powerful virtual hosting feature. Not only does this allow multiple Web sites to share the same pool of server processes, it allows them to share configurations too, making the server both easier to administer and quicker to respond. However, each Web site still needs to have its own IP address. The server therefore needs either multiple network interfaces installed or, alternatively, the ability to multiplex several IP addresses on one interface, known as aliased IPs; all modern operating systems can do this.

  • Name-based virtual hosting: Apache also supports virtual hosting based on its name. This allows multiple Web sites to share the same IP address. This also uses requirements in HTTP/1.1 (specifically, the Host: header) that allow Apache to determine which host is the target of the request sent by the client. The advantage of name-based virtual hosting over IP-based virtual hosting is that the server’s network configuration is much simpler. However, a drawback is incompatibility with pre-HTTP/ 1.1 clients. Fortunately, these are now rare and account for 1 percent or less of Internet traffic; but if that 1 percent might be important to you, then you need to consider name-based hosting carefully.


Configuration File Port Number Main Server Child Process Home Directory 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Peter Wainwright 2004

Authors and Affiliations

  • Peter Wainwright

There are no affiliations available

Personalised recommendations