Name Based Virtual Web Servers

This method allows a computer with only one IP address to host many virtual web servers. The HTTP/1.1 protocol allows the web server to state by which names it wishes to be accessed. The great advantage of this method is that a practically unlimited number of servers can run on one computer and, furthermore, it simplifies configuration and use. The main disadvantage is that the client must support this part of the protocol. New browsers do this, but there are still older versions in use that do not.

The configuration of virtual web servers is achieved by means of the keyword NameVirtualHost. For example, the two virtual web servers www.universe.dom and www.cosmos.dom are defined for the IP address Both names must be entered in the DNS server for the IP address. The definition is as follows:



ServerName www.universe.dom ServerAdmin [email protected] DocumentRoot /srv/www/htdocs/universe ErrorLog /var/log/httpd/universe/error.log CustomLog /var/log/httpd/universe/access.log common



ServerName www.cosmos.dom ServerAdmin [email protected] DocumentRoot /srv/www/htdocs/cosmos ErrorLog /var/log/httpd/cosmos/error.log CustomLog /var/log/httpd/cosmos/access.log common


If individual log files are defined for each virtual web server, the necessary directories and files need to be created first. They are not created automatically when Apache starts.

Was this article helpful?

0 0

Post a comment