The term Virtual Host refers to the practice of running more than one web site (such as site1.mysite.com and site1.mysite.com) on a single machine. Virtual hosts can be "IP-based", meaning that you have a different IP address for every web site, or "name-based", meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.
Use Case: I have a static IP address but no registered domain attached to this IP. I wanted to run some test sites, so this this is what I did:
1. Go to a site like freedns.afraid.org which provides free DNS subdomain hosting. They also provide a range of interesting domain names on which I can create my own subdomains.
2. At this site I made these links
3. In httpd configuration file etc/httpd/conf/httpd.conf I added the following directives
Listen 80 NameVirtualHost *:80 # I add this dummy entry first, which will redirect users # who enter URL 999.999.999.999 to DocumentRoot /var/www/default <VirtualHost *:80> ServerName whatever.something.com DocumentRoot /var/www/default </VirtualHost> # route site1.mysite.com to /var/www/content1 <VirtualHost *:80> ServerName site1.mysite.com DocumentRoot /var/www/content1 ServerAlias www.site1.mysite.com </VirtualHost> # route site2.mysite.com to /var/www/content2 <VirtualHost *:80> ServerName site2.mysite.com DocumentRoot /var/www/content2 ServerAlias www.site2.mysite.com </VirtualHost>
4. After re-booting Apache server, I can now access pages located at /var/www/content1 using URL site1.mysite.com