I've just created a new Windows XP VM on my Mac using VMware Fusion. The VM is using NAT to share the host's internet connection.
How do I access a Rails application, which is accessible on the Mac itself using http://localhost:3000
?
I've just created a new Windows XP VM on my Mac using VMware Fusion. The VM is using NAT to share the host's internet connection.
How do I access a Rails application, which is accessible on the Mac itself using http://localhost:3000
?
On the XP machine, find your IP address by going to the command prompt and typing ipconfig
. Try replacing the last number with 1 or 2. For example, if your IP address is 192.168.78.128, use http://192.168.78.1:3000.
You can use your host Mac's (or any other Mac on the network) 'local' name:
http://macname.local:3000/
where macname is the network name of your host (or other desired) Mac.
For future visitors: once you've got the IP address figured out, you can add an entry to the Windows hosts file, which is located at C:\Windows\system32\drivers\etc\hosts, to map the IP address to a (virtual) server name. Add a line like this:
192.168.78.1 myrubyapp
Now you can access the site in IE at the address http://myrubyapp:3000
If you use virtual hosts under Apache you'll need this to provide the correct server name.
As this question is quite old and referring to XP, here is an alternative for new OSs;
If you're rocking Vista or Windows 7 as the Guest OS, and you have Virtual Hosts setup in the Host via Apache, here's how to setup:
In the Host OS, you need to ensure the network connection is done via NAT;
Then, In the Guest OS;
Add a line to the file such as:
[default-gateway-IP] www.example.com
[default-gateway-IP] example.com
Save
http://www.example.com
or http://example.com
in IE<gateway-ip
> and hit http://<gateway-ip
>:3000 in your browser.Gotcha: You must have http:// in the address or IE will give you "The webpage cannot be displayed".
For Django it's important to do the following:
./manage.py runserver [default-gateway-IP]:8000
because
https://docs.djangoproject.com/en/dev/ref/django-admin/
Note that the default IP address, 127.0.0.1, is not accessible from other machines on your network. To make your development server viewable to other machines on the network, use its own IP address (e.g. 192.168.2.1) or 0.0.0.0 or :: (with IPv6 enabled).
I just spent an hour trying to get this to work following the steps on SO but mine ended up being a bit different.
VMWare settings
1.) Set VMWare connection to NAT
2.) run > cmd > ipconfig > copy Default Gateway value
3.) edit hosts file (c:/Windows/System32/drivers/etc/hosts)
<gateway-ip> yourserver.local
OS X settings
1.) edit Apache config (e.g., sudo vim /etc/apache2/httpd.conf)
NameVirtualHost 127.0.0.1 <VirtualHost 127.0.0.1> DocumentRoot "/path/to/your/project" ServerName yourserver.local <Directory "/path/to/your/project"> AllowOverride All Options All </Directory> </VirtualHost>
2.) Edit your hosts file (sudo vim /etc/hosts)
127.0.0.1 yourserver.local
3.) Restart Apache (sudo apachectl restart)
I found that I had to switch the connection setting on VMWare in order to restart the connection before these settings worked for me. I hope this helps.