Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What’s the easiest way to access local websites from a Parallels / VMWare Fusion virtual Windows machine?

  1. Develop a Rails app on your Mac.
  2. Have a virtual Windows box using Parallels (on the same computer).
  3. Want to test it in IE…
  4. …without deploying it to staging
  5. …or attempting to run your Rails environment within Windows

Is there any way to conveniently access port 3000 on my Mac from within Windows?

like image 234
Alan H. Avatar asked May 24 '12 23:05

Alan H.


1 Answers

This should be pretty straight forward (for non-subdomained Rails apps). It definitely gets more complicated with subdomains.

Non-Subdomained App

  1. From your Mac terminal:

    ifconfig -a

  2. Copy the assigned IP address (e.g., 192.168.1.100)

  3. Switch to Parallels, open IE and enter the IP address in the address bar. Don't forget to add the protocol and port number of the running Rails app. For example:

    http://192.168.1.100:3000

  4. Voilà! Rails app.

Subdomained App

You should probably already be using something like lvh.me to ease the burden of creating subdomained applications locally (see ASCIICasts 221: Subdomains in Rails 3). It doesn't seem to be so straight-forward on Windows though.

  1. Edit the Windows hosts file. It should be located somewhere like C:\WINDOWS\system32\drivers\etc\hosts

  2. Assuming your IP address is the same as above, add a line that looks similar to this, and save:

    192.168.1.100 lvh.me sub1.lvh.me sub2.lvh.me ... subN.lvh.me

    Where sub1, sub2, ..., subN are the subdomains that you want to access from IE.

You should now be able to access http://sub1.lvh.me:3000 from IE.

A Final Note

I was getting pretty tired of looking up my DHCP allocated IP address every time, so I created a new Network location in OS X called Home that uses DHCP with a manually assigned IP address. That way, I can at least save some time when I'm working from home. Just remember to switch locations when you join a different network. YMMV :)

like image 112
Curtis Avatar answered Oct 17 '22 06:10

Curtis