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

Find File System Called Hosts - 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



I have shown you only the most basic way of setting up virtual hosts; you can use almost any directive inside a <VirtualHost> container, and these directives will override or work alongside the equivalent directive in the main server configuration.

The only limit to how many virtual hosts you can create are the limitations of the physical machine that Apache is running on. Apache uses file descriptors, integers denoting files that are open, for any log files, in addition to another twenty used by the server itself. On most UNIX platforms, the limit to the number of file descriptors in use is 64, which can be used up very quickly. Changes to the configuration of the operating system can increase this, but a more suitable solution is not using the ErrorLog or TransferLog directives within the <VirtualHost> blocks, which will make Apache write only to the main hosts log files and therefore reduce the number of log files in use. Additionally, some operating systems will need to have an extra network interface card for each IP address.   

If you are using Apache on a Windows XP desktop PC, for testing PHP or CGI for example, you now need to find a system file called hosts, which will be under the following path: C:WINDOWSsystem32driversetc. Open the file with Notepad and you should see something like this:

# space.
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
#     rhino.acme.com          # source server
#      x.acme.com                 # x client host       site1 site2

The IP Address for a local host is always To make it work you just need to add the virtual host name to the same line as the main host name, separated by a tab-space. This is similar to mapping your server's DNS settings.

You should now have enough information to begin creating and managing virtual hosts with Apache. There are many configurations that can be used, so experiment until you find one that matches your particular needs.

>>> 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: