1

I have XAMPP running on my desktop machine, and I do all my work on it with no issue.

http://localhost       ---> points to public_html
http://site1.localhost ---> points to site 1
http://site2.localhost ---> points to site 2
http://site3.localhost ---> points to site 3

Entering the above URLs in my web browser on the machine with Apache works great, and I can work on multiple sites within distinct subdomains.

But what I want to do now is to transfer Apache and all the files to another Windows 7 machine within the LAN, but still be able to view the subdomains from my main development machine.

With a vanilla XAMPP installation on the new hosting machine, entering the IP address of that machine (e.g. 192.168.1.10) into my development computer would send me to the main public_html folder.

But how do I set up subdomains such that I can access it externally? For example, http://site1.devmachine

Thanks for any help.

2 Answers2

4

edit %systemroot%/system32/drivers/etc/hosts of your workstation and add:

192.168.1.10 site1.devmachine

192.168.1.10 site2.devmachine

What this will do is resolve site2.devmachine to the IP address of your new dev server. Because you're sending along the host headers to the dev server when you make a request, Apache knows what virtual host to load.

Just so you know, .devmachine can be anything: you could even put realdomain.tld in there (although I don't recommend this; I found I'd forget about it and wonder why the site looked "old").

I found it easier to setup a wildcard in DNSMasq and do split DNS so that when I'm on my LAN, I can pull up the same site as when I'm accessing it remotely (I use *.dev.mydomain.com, * being replaced by client name; I also have the same wildcard entry for my real Internet DNS servers) at a client's doing a demo. Now when I want to setup a new site to work on, I just have to create a new virtual host in Apache and not worry about DNS.

gravyface
  • 13,947
  • 16
  • 65
  • 100
  • Oh, so in the same way I edit the hosts file on my host machine, I can do exactly the same on my client machine, and it will resolve correctly? Cool, thanks. –  Apr 19 '10 at 22:49
  • Yup, before I setup a DNS server at home, I used to put all my project sites (someclient.com etc.) in my dev machine's hosts file but eventually I setup DNSMasq on my Ubuntu dev server with a wildcard entry so that I didn't have to edit the hosts file anymore. – gravyface Apr 19 '10 at 22:54
  • +1, This is how i've always done it – grufftech Apr 19 '10 at 22:56
0

Add a DNS server to your network and create entries for site1.devmachine.local etc.

Get your dev machine to use this DNS server.

That might be overkill though. You could more easily add entries to the hosts file in c:\WINDOWS\system32\drivers\etc. This is on your devmachine only.

Add entries like this:

192.168.1.22 site1.devmachine.local

192.168.1.22 site2.devmachine.local

192.168.1.22 site3.devmachine.local

Seanchán Torpéist
  • 1,808
  • 2
  • 14
  • 10