Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The past few days I'm exploring how to setup a webserver (personal usage).. I'm a programmer not a sysadmin, so it's a lot trial and error for me.

What I have so far:

VM Workstation

  • Host: Windows 7
  • Guest: Ubuntu 11.04
    • apache, MySQL, PHP, bind9, etc.
    • samba file sharing
    • webmin

My goal is to create a wildcard .dev domain available from my host machine (Windows 7) pointing to a virtual host on the guest machine (Ubuntu).

So for instance; I enter www.domain.com.dev in a web browser on Windows 7, this should resolve to /var/www/sites/domain.com/www/htdocs on the virtual Ubuntu server.

I'm known with VirtualDocumentRoot so thats not going to be the problem but I'm clueless about the DNS configuration (especially to make it available on windows).

share|improve this question

1 Answer 1

You would do that in your hosts file. This tells you how to edit that: http://www.windowsreference.com/windows-7/edit-hosts-file-in-windows-7-windows-vista/

You cannot use wildcards in the hostsfile, so you will have to add each site individually, but it takes like 1 minute to add something once you got figured out how it works :)

You need the IP address of your guest machine. issue "/sbin/ifconfig" in your vm to find that. Also, the easiest way to get this to work networkwise is to have the network adapter in your virtual machine set to "Bridged Mode" - this way it will retrieve an IP address via DHCP from your local network. (I am assuming you have a standard home network with a DHCP router).

When you have the IP, open the hosts file and add entries. In my example the IP address of the VM is 192.168.1.20

192.168.1.20    mywebsite.dev www.mywebsite.dev
192.168.1.20    anothersite.dev www.anothersite.dev

This will cause mywebsite.dev, www.mywebsite.dev, anothersite.dev and www.anothersite.dev to hit the IP address of the VM.

share|improve this answer
    
It's bridged, if i hit GUEST-IP on windows it resolves to the current document root on ubuntu, which is nice. I can setup wildcard dns on ubuntu with bind9 right? So then i only have to maintain the windows hosts file... which is... ok =) –  Roland Franssen Jun 13 '11 at 10:33
    
You don't need BIND on the Ubuntu machine to take care of virtual hosts, those are handled in Apache. –  Frands Hansen Jun 13 '11 at 11:15
    
I got it working on ubuntu with dnsmasq; pointing *.dev to 127.0.0.1. For now i will manually maintain the windows hosts file with domain names i often use. –  Roland Franssen Jun 13 '11 at 11:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.