VMware Communities
chippper
Contributor
Contributor
Jump to solution

Fusion, Leopard & MAMP - looking for dead easy instructions

I'm struggling with trying to get my MAMP installation to show up under Fusion. Here is my configuration:

Running mac os 10.5.1

Fusion 1.1.1 - connected using NAT

Windows - XP sp2

on a MacBook Pro which connects to a wireless network via airport

What I'm trying to do is to:

1. Be able to test sites hosted via MAMP in fusion - that is, I have a local wordpress install, and want to test it in IE using Fusion

2. Be able to test the site from anywhere with my MBP - this computer hops from network to network every day, and sometimes I don't have any connection at all

- I'm not looking to be able to view the test site from another computer - I just want everything contained on my MBP.

I found this thread:

http://communities.vmware.com/message/782477#782477

But got kind of lost. Hence the title of this thread - I'm just looking for a walk through.

I know that it involves editing the hosts file, which is here:

C:\Windows\system32\drivers\etc\hosts

What I'm getting lost with is what to add to the file. Should it list the IP address windows itself is receiving? Right now that is 192.168.113.128. Would I then add:

192.168.113.128 mysites.dev <--- I made that name up

to the hosts file? then, to access the sites in IE - I would use the url: http://mysites.dev/wordpress (or whatever directory i need)?

I've sort of tried this, but haven't had success.

So, as I indicated, I'm just looking for a step by step process. Any help is greatly appreciated!

Reply
0 Kudos
1 Solution

Accepted Solutions
WoodyZ
Immortal
Immortal
Jump to solution

Okay I just tested this so I know it works... here is what I did...

Set the Virtual Machine Network to NAT and disconnected the Host from an active network to simulate not having Internet Connectivity per one of your requirements.

In a Terminal in OS X I typed "ifconfig -a" without the quotes to get the IP Address of "vmnet8" as this in the VMware NAT Adapter on the Host and the address I want to use in the Windows HOST File.

I edited the C:\Windows\system32\drivers\etc\hosts adding the following.

192.168.152.1 test.com www.test.com

Note: Your "vmnet8" IP Address may vary so obviously use yours not mine.

After editing the HOSTS File you must either reboot for the changes to take effect or in a Command Prompt type the following.

ipconfig /flushdns

I was then able from the Virtual Machine in IE's address bar type either of the following addresses and bring up the Mac's Web Server Content.

http://test.com or http://www.test.com

Is this what you wanted?

Anyway I've attached a file named EDITHOSTS.ZIP containing a NT Command Script named EDITHOSTS.CMD. Place the EDITHOSTS.CMD file in a directory that's in your %PATH% and you can then in a Command Prompt type EDITHOSTS and then press Enter. It will load the HOSTS file and then Flush the DNS Resolver Cache after you close the HOSTS file and report that the flush was successful or not. This makes it much easier then manually navigating to the HOSTS file and editing it then rebooting or manually issuing the ipconfig /flushdns command for the changes to take place.

Note: I used test.com and www.test.com however there is an actual test.com domain and because I've modified the hosts file it does not actually go to the real test.com site but the site as defined by the ip address in the hosts file which was the Apache Server on my MBP.

File Attached: EDITHOSTS.ZIP

View solution in original post

Reply
0 Kudos
18 Replies
WoodyZ
Immortal
Immortal
Jump to solution

Okay I just tested this so I know it works... here is what I did...

Set the Virtual Machine Network to NAT and disconnected the Host from an active network to simulate not having Internet Connectivity per one of your requirements.

In a Terminal in OS X I typed "ifconfig -a" without the quotes to get the IP Address of "vmnet8" as this in the VMware NAT Adapter on the Host and the address I want to use in the Windows HOST File.

I edited the C:\Windows\system32\drivers\etc\hosts adding the following.

192.168.152.1 test.com www.test.com

Note: Your "vmnet8" IP Address may vary so obviously use yours not mine.

After editing the HOSTS File you must either reboot for the changes to take effect or in a Command Prompt type the following.

ipconfig /flushdns

I was then able from the Virtual Machine in IE's address bar type either of the following addresses and bring up the Mac's Web Server Content.

http://test.com or http://www.test.com

Is this what you wanted?

Anyway I've attached a file named EDITHOSTS.ZIP containing a NT Command Script named EDITHOSTS.CMD. Place the EDITHOSTS.CMD file in a directory that's in your %PATH% and you can then in a Command Prompt type EDITHOSTS and then press Enter. It will load the HOSTS file and then Flush the DNS Resolver Cache after you close the HOSTS file and report that the flush was successful or not. This makes it much easier then manually navigating to the HOSTS file and editing it then rebooting or manually issuing the ipconfig /flushdns command for the changes to take place.

Note: I used test.com and www.test.com however there is an actual test.com domain and because I've modified the hosts file it does not actually go to the real test.com site but the site as defined by the ip address in the hosts file which was the Apache Server on my MBP.

File Attached: EDITHOSTS.ZIP

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

Hi, Chippper. Yes, that discussion thread got a little complicated, didn't it? Not to worry.

For anybody who's new to this issue, here is a quick summary of the problem. Macs will make up a local name for themselves, such as "joe-cools-computer.local". Unfortunately, when you run an Apache Web server under Mac OS, it will assume that everybody in the world can use that name. When a Web browser sends an HTTP request to Apache, it will reply with a redirection message saying, in effect, "Call me back at joe-cools-computer.local". But no other computer in the world (not even a virtual machine inside this Mac) can use joe-cools-computer.local to find Apache, because that name has no DNS translation.

Just giving your Mac a name with a DNS translation, or putting joe-cools-computer.local into your DNS server, won't be good enough for mobile systems. If your Mac's primary IP address changes all the time, you'll have to keep updating DNS all the time. But DNS updates don't propagate instantly. This is a recipe for frustration.

So here's a solution in two parts:

1. Make sure that, no matter what happens to your Mac or to your virtual machine, there's an IP address by which your VM can always call your Mac.

2. Make sure that your VM associates joe-cools-computer.local (or whatever crazy name your Mac thinks it has) with that IP address.

The secret to part 1 is that virtual machines can have more than one virtual network adapter. It's just like sticking more than one Ethernet card into a PC: each can have its own IP address and its own network connection.

To pull this off, edit the virtual machine's Settings while it is powered off. (Just suspending the virtual machine is not good enough; you actually have to shut down Windows or Linux inside the VM.) Add a network adapter and place it into host-only mode. You will leave this new, second network adapter in host-only mode forever. You can move the primary virtual machine around among the network modes freely, but the purpose of this second adapter is to ensure that the virtual machine can always call the Mac by the IP address the Mac uses on that private, host-only network.

You will need to find out what your Mac thinks its address is on the host-only network. Open a Terminal window on your Mac and give the command ifconfig vmnet1. For example:

In this example, my Mac's IP address on the host-only network is 172.16.9.1.

Now to pull off part 2. You will need to add an entry to the virtual machine's host file that associates that IP address with whatever name your Mac has made up for itself. To continue our example:

172.16.9.1 joe-cools-computer.local

is what you would want to put into your VM's C:\Windows\system32\drivers\etc\hosts -- assuming, of course, your VM is running Windows. On a Linux VM, you'd edit /etc/hosts similarly, and also edit /etc/nsswitch.conf to ensure that the local hosts file is consulted for hostname lookup in addition to DNS and the many other supported name-services.

With this done, your Mac's Apache will be able to get away with calling itself joe-cools-computer.local, because your VM will associate that with a name that always resolves to the host Mac.

Tip o' the hat to rcardona2k, who helped me see how useful a second, host-only network adapter for the VM is in this circumstance.

chippper
Contributor
Contributor
Jump to solution

Many thanks to both of you!! It's now working... mostly.

I'm not even sure if the issue I'm having is exactly Fusion's fault or not.

Now that MAMP works and I can view files in Fusion, I want to get my wordpress install going. I have it installed locally, and can see it on my mac browser at

localhost:80/wordpress

However, it just flat out refuses to work in Fusion. Using the methods you both suggested, I edited the host file, and other MAMP files work correctly (for instance, my joomla installation). But nothing I do lets me see my wordpress blog in Fusion. I've re-installed WP and MAMP, but I keep getting the error "Internet Explorer cannot display the webpage".

Maybe this is more of a MAMP/Wordpress issue - but I'm stuck scratching my head. I don't know why Fusion would be able to see other MAMP files, but not the wordpress installation.

Any thoughts? You all have been extremely helpful! Thank you!!

Reply
0 Kudos
rcardona2k
Immortal
Immortal
Jump to solution

You can't access MAMP from XP using localhost because that resolves to 127.0.0.1 meaning your XP system not OS X. You could redefine localhost by removing it's separate line in hosts and placing it on your line with your 172.* address, e.g.

172.1.2.3 myOSXcomputer.local localhost

Reply
0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

Technical Nitpick: Fusion is a Mac Application that allows you to virtualize different OSes and as such if you're talking about something your doing in, say, Windows you should refer to Windows and not Fusion per-se. It just make it easier to see the whole picture clearer.

Anyway if your using localhost:80/wordpress from IE in Windows unless you modified the default HOSTS entry of 127.0.0.1 localhost in Windows then you are not getting to then Mac as localhost by default is just that the Local Host meaning the system itself and not in the scene of Host OS as in Mac is the Host OS and Windows is the Guest OS.

I have Apache running on my MBP in order to work with the websites I maintain and test in IE in Windows and when I modify the HOSTS file so I can use the fully qualified domain name and test the local content before pushing it to the real Web Server I have no problems using the configuration I suggested however I have not used the apps your using and cannot offer anything more that making sure you have things configured right in relegation to the apps your using. (This is why I scripted the EDITHOST.CMD file to make changes on the fly easy.)

Maybe you need to look closer at Brian's suggestion as it may work better for what your trying to do then what I suggested.

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

Hey, chippper, I assume that, when you try to hit your wordpress installation from the virtual machine, you're using a URL like http://joe-cools-computer.local/wordpress rather than http://localhost:80/wordpress. As other posters implied, "localhost" means "this computer", and your virtual machine is not the same computer as your Mac.

Other posters showed how you can redefine "localhost", but I personally try to avoid that practice. I always forget I've done it, and then I get very confused when I try to use localhost for its original purpose ("this computer"), and it doesn't work. Also, other applications may rely on localhost, not necessarily in user-visible ways.

Given that your browser in the virtual machine can hit the Apache install in your Mac, you know that the network configuration is fine. Now's the time to start using standard Web troubleshooting techniques.

  • Check Apache server logs

  • Open a command-line session in the client computer (in this case, the VM), telnet to port 80 on the server, and type HTTP using your fingers (such as GET / HTTP/1.0).

  • Install a browser plugin such as Firefox's Live HTTP Headers so that you can see what the browser is trying to send

Reply
0 Kudos
chippper
Contributor
Contributor
Jump to solution

Ach! I see now that my post was misleading. I'm very sorry -

I'm not trying to access my site in Fusion via localhost:80. I followed WoodyZ's extremely helpful instructions, and everything worked out great. I edited my hosts file in XP so that it had the IP the terminal command brought up, and I assigned it a different site name. It was something like this:

192.abc.e.fgh mysites.dev

Now, I can see my MAMP sites in Fusion when I enter a URL with the appropriate directory:

in IE} http://mysites.dev/joomla

Works like a charm!

What the problem is that Wordpress, and Wordpress alone, just flat out refuses to show up, no matter what I do. I'm just curious if anyone else does any work with Wordpress on here who might have some insight?

Reply
0 Kudos
fitter_man
Contributor
Contributor
Jump to solution

I am trying to do what you suggest (in Part 1, adding a second network adapter) but when I go to the settings, the "" control only allows me to add a shared folder, in Fusion 1.1. I upgraded to 2.0, thinking may that would be different, and in the network adapter setting, it shows mine, but here again, the "" control is disabled. What am I missing?

Reply
0 Kudos
fitter_man
Contributor
Contributor
Jump to solution

Ignore my post. I re-read brianriceca's and realized I hadn't shut down the VM. Duh.

Reply
0 Kudos
ottosmo
Contributor
Contributor
Jump to solution

I ran into a similar problem in a different situation, and found a solution. Not sure chippper if this is relevant but it might be.

I am running Fusion under OSX as the host OS and WinXP as guest. In my case my local Wordpress server is on the XPvm with xampp, more-or-less the reverse of what you describe. I initially had no connectivity between the VMs until I followed the instructions in this thread to set up a second virtual network adapter.

Anyway, the point is that eventually I did get it set up with entries in the hosts files on both the VM and the OSX side so that (the name I chose) could see the Apache instance, but still Wordpress didn't work.

It turned out that there's a setting within Wordpress itself that specifies the base URL of all Wordpress links. I had to login to Wordpress admin within its native vm, and change that from to bloghost/wordpress.

After that Wordpress generated URLs that the OSX side liked, and since I had configured the guest OS to understand the same name in its hosts file, it liked it too.

Reply
0 Kudos
remoteONE
Contributor
Contributor
Jump to solution

Ok I give up, I need help now ,

Ive followed every possible instruction on this and other forums to no avail.

I followed this instruction here to-the-letter and same result... no connection to the MAMP web server.

I powererd down the WinXP VM and setup the second Host Only network adapter.

Got the Mac IP address from terminal.app

edited HOST file in XP :

#vmnet1: host only mode network adapter
192.168.172.1  joe-blows-macbook.local localhost

then rebooted.

Still no worky... "http://joe-blows-macbook.local/"  nor "http://localhost/"  .. nothing works!

edited HOST file again in XP :
192.168.172.1  joe-blows-macbook.local

then rebooted.

Still no worky...  "http://joe-blows-macbook.local/"   nor .. "http://192.168.172.1/" nothing works!

1. Now I assume my computers name is correct from the terminal command prompt?

ie "Joe-Blows-MacBook:~ blow$ ifconfig vmnet

2. The URL box in IE case-shifts the computers name from "http://Joe-Blows-MacBook.local/" to "http://joe-blows-macbook.local/" .

   Can I assume its of no consequence

Nothing I try works !  Im going out of my brain over this!  Help greatly and humbly appreciated

Reply
0 Kudos
gbullman
Expert
Expert
Jump to solution

Your statement of "and setup the second Host Only network adapter." is confusing me.  This should work with any of the 3 default adapters provided with Fusion (Bridged, NAT, or Host Only), For Bridged the Mac would need to be connected to a network, not sure if NAT will work without a network or not.

What URL do you enter in the Mac's browser to view the MAMP site?

I ended up purchasing MAMP Pro for the Mac because I needed to support more than one site & the restriction of MAMP that it is always localhost is a bit more problematic when you're trying to access it from another computer (physical or virtual).  MAMP Pro makes it easy to give each site a more meaningful name

Another thing to confirm is that MAMP by default listen's on port 8888.  If you did not change that setting in MAMP then in the URL address in the browser on your windows machine should be: http://joe-blows-macbook.local:8888 since you are not using the default http port of 80.

Doing this really should be pretty straight forward, it is just a matter of figuring out what isn't lining up.

Reply
0 Kudos
remoteONE
Contributor
Contributor
Jump to solution

Thanks gbullman,

RE: MAMP port  8888.
Using the URL http://joe-blows-macbook.local:8888  improves things slightly. I get to view the folder file structure that MAMP is serving:Screen shot 2011-09-14 at 5.04.50 PM.png

But selecting any folder (eg http://joe-blows-macbook.local:8888/3G/) containing the wesite files(index.php and .htaccess etc)  renders no web pages. The site won't load and IE just gives me the "Internet Explorer cannot display the webpage" message.

I dont think I need MAMP pro as all the sites should be accessed the same way as in MAMP  ie. http://joe-blows-macbook.local:8888/store1_folder/ ,http://joe-blows-macbook.local:8888/store2_folder/. But I can see how having Pro could make life easier in this regard.

RE:  "and setup the second Host Only network adapter."   I mean: "and setup the second  network adapter as Host Only" as reccommended in the setup proceedure in this post. So I have 2 network adapters in vmware for the WinXP VM. One is NAT,  the second, used for MAMP sharing is Host Only.

Cheers

Reply
0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

not sure if NAT will work without a network or not.

As I said in my first reply, "Set the Virtual Machine Network to NAT and disconnected the Host from an  active network to simulate not having Internet Connectivity per one of  your requirements." to the OP... so, it does work with NAT when not connected to a Physical LAN.

Reply
0 Kudos
remoteONE
Contributor
Contributor
Jump to solution

WoodZ,
There are two different sets of instructions in this thread. Your's and that of brianriceca. I followed brains, as I had tried a similar instruction to yours previously.
Your method uses NAT, brains uses Host Only. I've previously tried your method with the same results and have again re-tried your method.

Get the same results. "http://joe-blows-macbook.local:8888/3G/ wont load ant web content.

Cheers.

Reply
0 Kudos
gbullman
Expert
Expert
Jump to solution

I suspect you have one of two things going on since you are now reaching the site.

The .htaccess in either the root or 3G subdirectory is not configured properly to read the index.php, index.html or whatever should be the default "page" of your site.  I've always kind of muddled my way through getting those correct, but you probably need a line something like;

DirectoryIndex index.php

or maybe (not sure if this is valid)

DirectoryIndex G3/index.php

or

DirectoryIndex index.html

There are a few tutorials out on the net on the contents of .htaccess for different situations so you'll probably have to do a little research to figure out what you need.

Other possibility is my experience with MAMP and some site frameworks are they can only be successfully access from 1 URL.  In other words if you're viewing the site fine on your Mac with http://localhost:8888 but are trying to access from your Windows XP guest as http://joe-blows-macbook:8888 you may not get the same results.  That was one of the reasons I went with MAMP Pro (also I needed to support above 5 different sites so it became difficult to manage with just MAMP.  I'm mostly using Drupal for the sites I support and they are sensitive to what URL you access them with.

Try having the hostname entry in your XP hosts file match the URL you use on the Mac (do not include the :8888 in hosts) to see if you get better results.  If that happens to be localhost you probably don't want to leave it that way because other things may break on the XP guest.

Reply
0 Kudos
remoteONE
Contributor
Contributor
Jump to solution

MAMP serves up the many stores under htdocs without issue to the MacBooks OSX Browsers fine, Local .htaccess files are different than the live versions and it would be good to be able to have a local "url" to access each loacaly ( the same way live hosting uses parked and addon domains)

Is that what MAMP PRo allows you to do?

I think this is a MAMP issue rather than a VMware issue, because there is a strange thing that happens when accessing the file structure under htdocs.

This occurs with both IE on WinXP VM and FF on OSX.

I have two folders: htdocs/A/  and htdocs/B/ .

Under both these folders are .jpg files .

The files under both /A and /B have exactly the same owner/group and permissions settings.

But only the files under /A are displayed in a browser. Files under /B are not listed.

Very strange indeed.

Reply
0 Kudos
gbullman
Expert
Expert
Jump to solution

I agree this is not a Fusion issue, once you get to the window in your previous post Windows & Fusion are working.  I'd be willing to be if you tried accessing those sites from another physical Windows PC (this time you would put the Mac's real IP address in the hosts file) you would get the same behavior you're getting from your virtual one.  In fact, I suspect accessing from another Mac (they'll find each other via bonjour so you can use the actual hostname of the Mac running MAMP with .local:8888 appended to it, http://MAMPmacHost.local:8888)  you will see odd behavior as well.

MAMP Pro allows you to set up a separate URL for each site & it removes the constraint that the files have to be stored in htdocs.  That alone was a big help for me since my hosting company uses ~/public_html as the web root directory.  I can restore a backup of our live site to a project folder within my mac $HOME directory and access it via MAMP with no changes (had to set up a couple of simple symbolic links one time to get that all to work).

In my opinion once you're supporting more than 1 site MAMP Pro is probably worth the money so you don't waste time figuring out stuff like this.  It even has hooks to DynDNS and services like that so you're clients can view the site off your Mac (with 8888 directed to your Mac on your router).

Good Luck.

Reply
0 Kudos