Home arrow Apache arrow Page 2 - Configuring and Using Virtual Hosts in Apache

Edit the Main Configuration File - Apache

Begin creating and managing virtual hosts with Apache with this clear explanation from Dan Wellman. He explains what virtual hosts are and illustrates a basic way of setting up virtual hosts.

  1. Configuring and Using Virtual Hosts in Apache
  2. Edit the Main Configuration File
  3. Virtual Host
  4. Find File System Called Hosts
By: Dan Wellman
Rating: starstarstarstarstar / 107
June 30, 2004

print this article



True to its cutting edge character, Apache HTTP server was one of the first servers to begin providing support for virtual hosts and fortunately, configuring them is relatively easy. The mod_vhost_alias Apache module comes as standard with both the compiler and pre-compiled distributions. So no matter how you installed the software, it should be present on your system. For the purpose of this article, Iím assuming that you have already configured Apache for running your main host.

There is a little work to be done in Apacheís main configuration file httpd.conf. Open this file by either browsing to the directory Apache is installed in and opening httpd from within the conf directory or, on a Windows platform, by selecting Edit the Apache http.conf configuration file from the start menu.

Scroll right down to the bottom of the file to section 3, the virtual hosts section. Everything that you need to do in Apache to get a virtual host up and running is done within this section. There is already a commented out virtual host configuration for reference; you can leave this example in place for referring to later or you can remove the hash symbols at the start of each line and adjust the example -- itís really up to you.

The virtual host directives take precedence over the main server configuration, so to make sure that requests to your main host are not confused with requests to your virtual host, you have to add the main host as the first virtual host. This will ensure your main host stays as the default host. For the following example, Iíve used a main server name of site1.co.uk and Iím adding a virtual host called site2.co.uk, highly imaginative I know but it serves (no pun intended) to illustrate the point. As itís simpler, weíll look at name based virtual host configuration first.  

>>> More Apache Articles          >>> More By Dan Wellman

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Apache Unveils Cassandra 1.2
- Apache on ARM Chips? Dell and Calxeda Help M...
- The Down Side of Open Source Software
- VMware Unveils Serengeti for Apache Hadoop
- SAP Takes Steps to Improve Hadoop Integration
- Looking to Hone Apache Hadoop Skills?
- How to Install Joomla on WAMPP
- Working with XAMPP and Wordpress
- GUI Available for Apache Camel
- Reduce Server Load for Apache and PHP Websit...
- Creating a VAMP (Vista, Apache, MySQL, PHP) ...
- Putting Apache in Jail
- Containing Intrusions in Apache
- Server Limits for Apache Security
- Setting Permissions in Apache

Developer Shed Affiliates


Dev Shed Tutorial Topics: