Ubuntu: How do I test virtual hosts in Apache before I buy the domains?


Is it possible to setup an Apache virtual host without a domain name, I just want to use my IP to test my website until I get a domain name.

Examples in Apache documenation only seem to have domain name aliases like so

<VirtualHost *:80>  ServerName www.otherdomain.tld  DocumentRoot /www/otherdomain  </VirtualHost>  


Please note that the standard name-based virtual hosts depend on receiving a correct domain name from your browser request to serve the appropriate site (vhost).

The right way to test out multiple vhosts on your local machine is to give them any domain name you can think of, and simply map that domain to (localhost) by adding it to /etc/hosts.

For example:

  &ltVirtualHost *:80>      ServerName www.iamnotawizard.com      DocumentRoot /var/www/iamnotawizard  </VirtualHost>  

will work great as long as you add this line to /etc/hosts:      www.iamnotawizard.com  
  • Note that Apache will throw a Could not reliably determine server's FQDN warning whenever started/restarted; you can safely ignore it.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »