Virtual hosts are an integral part of the Apache HTTP server; after all they have an entire section in the httpd.conf file devoted exclusively to them. But what are they and what can they be use for?
In Internet terms, your web server is the host that serves the web pages that make up your site. Your server and the web browsers that are used to access your site interact in what is known as the host/client relationship. If your server hosts just one site, it would be known as a dedicated server, but these are usually only necessary for running large sites with high traffic.
Virtual hosts are separate hosts that are run from the same server as a main host, or site. This means therefore that one server can host several separate web sites simultaneously, each accessed via separate DNS names. Visitors to your site will be unable to distinguish between virtual or dedicated sites. The main difference between hosts and virtual hosts is that hosts have unique IP addresses and virtual hosts do not necessarily have individual IP addresses. There are in fact two types of virtual host; IP based and non-IP or name based. IP based, as the name states do not share an IP address, non-IP based do. IP based virtual hosts are useful for when you want to manage more than one site on the same server so that all hosts inherit the characteristics defined by your main host, but for some reason, such as when using SSL for example, a unique IP address is necessary.
The fact that virtual hosts are not required to have unique IP addresses is largely what brought them about in the first place; because of the limitations of IPv4 (Internet Protocol version 4) and the explosive growth of the Internet, something was required to solve the problem of the rapidly dwindling supply of available unique IP addresses. Thus, server software began to incorporate support for non-IP based virtual hosts. Something to make note of at this point is that HTTP1.1 was also implemented with support for virtual hosts and there are still some browsers out there that donít support HTTP1.1, so therefore Apache has to handle requests from older browsers differently. Instead of receiving hostname as part of the HTTP header and opening the correct homepage in that way, it has to serve a list of available hosts. This situation will probably only arise very infrequently however, as even browsers that only support HTTP1.0 will usually have an extension to add the hostname to the HTTP header.
Virtual hosts are not the only solution to the problem of IPv4 limitations, as a point of interest, IPv6, the latest Internet Protocol incarnation, is already being used by some servers and browsers. This version is based on a 128bit IP address format instead of the old 32bit format used by IPv4, which increases the number of unique IP addresses exponentially.