Running OSX MAMP test server on VirtualBox Windows 7 - macos

I have MAMP server and several test sites installed on my OSX 10.6.3. I just installed Windows 7 on a VirtualBox virtual machine. I have managed to successfully share folders to the Windows installation, but I am wondering if I can run my MAMP sites in Windows without installing a different Localhost there.
Does anyone know if this is possible? It would be very convenient if I could test my sites in both operating systems all hosted from a single location.

Although this is probably too late for the OP, posting here for others.
If you're just trying to access your Mac localhost, then all you need to type into
the guest os is 10.0.2.2.
If you're trying to access named virtual hosts such as 0.dev or dev.local, then you need to modify the guest os host file to map the domain names to the host os.
In the case of Windows 7, you simply navigate to C:\Windows\System32\drivers\etc then modify the hosts file with admin privs.
Inside you will you will see the following line commented out
# 127.0.0.1 localhost
Below it, add entries for each of the virtual hosts you wish to use
10.0.2.2 maclocalhost
10.0.2.2 0.dev
10.0.2.2 dev.local

I just setup three VirtualBox VMs today specifically for connecting to MAMP on an OS X host. Thought I’d share my method of doing this since it works well for me.
While accessing the localhost via 10.0.2.2 I find using a host only network to be a much more flexible & reliable way to handle scenarios. You get a another IP address so debugging network issues on a VM can work as well.
First, go to VirtualBox -> Preferences…. Then choose Host-only Networks. You should have a vboxnet0 adapter in place. If not, add one.
Once you are set with that, select the vboxnet0 adapter & click the small yellow screwdriver icon on the right side of that window to edit the options. Under the Adapter pane, set the IPv4 address to 192.168.56.1 & the network mask to 255.255.255.0. Leave the IPv6 area blank. The IPv6 network mask length should be 0.
The DHCP server stuff should be blank, like so.
Okay? Got that set. Now choose your VM. In my example it’s the IE8 - Win7 image for web development testing. And click the Settings gear. Then click the Network icon. And now choose Adapter 2. And choose Host-only Adapter from the pull down menu for Attached to:. And then choose vboxnet0 under Name:. The rest of the options should just be the standard options.
Now, when you startup your Windows VM, launch Internet Explorer. And go to the address:
http://192.168.56.1
With that, you should be set! But if you are used to using Macs, be 100% sure you have the http:// in front of the address. I got embarrassingly stuck when I just entered the straight 192.168.56.1.
And as Jon Jaques says in his answer you can edit the hosts file in Windows to point to the IP address of 192.168.56.1. It will make your life easier & if you know how to setup named virtual hosts in MAMP (not hard) you can setup a few different sites to test via VirtualBox.
Oh, also, if you are used to using your machine name in OS X to connect to MAMP—like with the name LogicArtist.local if that is your machine’s name—you are not in any luck. The VirtualBox built in software router claims to pass multicast data, but it doesn’t. Check out this post which explains it in more detail.
In the environment created by VirtualBox there are multiple NICs that
claim to be multicast capable. However, they are lying. Furthermore,
because of the way VirtualBox assigns metrics, your outgoing socket
will get assigned to a liar who will happily gobble up your multicast
messages and not send them on.
Annoying, but you can work around stuff like that by at least editing your hosts file to have an entry for LogicArtist.local like this:
192.168.56.1 LogicArtist.local
Definitely not as elegant as a true multicast address being passed, but at least the brief amount of time you will be spending in Windows to debug things will be made easier but adding that entry.

MAMP Pro lets you specify the port for each host. Choose a unique port for your desired host. In your virtual machine simply type http://10.0.2.2:PORTNUMBER and your site will appear. Example: I created a host called localuproar and assigned it port number 9000. In VirtualBox I opened up Internet Explorer and typed http://10.0.2.2:9000, and my site appeared.
You can mess around with hosts files as described in previous posts, but I think it is easier to simply type in a port number.
On a related note, there is a very easy way to create virtual machines for all versions of Internet Explorer (http://osxdaily.com/2011/09/04/internet-explorer-for-mac-ie7-ie8-ie-9-free/):
Launch Terminal
Type this in your terminal window
curl -s https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh | bash

Related

How to force windows 10 to refresh network location

I have a raspberry pi with Samba share and attached piDrive. I currently backup from windows to that networked drive (old address 192.168.1.117).
I've forced the pi to use eth0 only and assigned a static IP address.
After a samba restart and PC restart, the pi3 shows as a network device (\RASPBERRYPI3) however on clicking I get 'not found' and an 0x80070035 error.
If I manually add the new IP address to a mapped drive, it works fine (192.168.1.199) and I've successfully added it as a new drive. The issue is windows won't allow me to backup using the built in backup feature as it will only allow a network browseable location (the other computers on the network \raspberrypi3). Is there anyway I can force this to rescan for the new IP address or reset it in some way to allow access?
Many thanks,
Luke
The ONLY way I could do this after 6 hours of tinkering was to change the raspberry pi hostname. This was much easier than anything else, despite having to resolve a few issues on the pi side. I did try changing it initially (windows found and accessed no trouble) then changing it back, but again windows couldnt find it? Eventually I just opted for sticking with the changed name and resolved the Pi-side issues. Not ideal but it was the only thing that would work for me.

Vagrant with Hyper-V Provider to run Laravel Homestead

Using a new install of Laravel with Laravel Homestead I've been trying to get Vagrant to boot, but it keeps timing out. I tried using the Default virtual switch, as well as the DockerNAT and NewInternalVirtualSwitch which is a virtual switch I added using the Hyper-V Manager.
I know I can leave the provider as VirtualBox and turn off Hyper-V, but since we use Vagrant and Docker for different application doing this over the last couple days has become tedious since Docker for Windows on Windows 10 Pro requires Hyper-V to be on so each time you have to shut down and restart in either direction.
Has anyone gotten Laravel Homestead to work using the Hyper-V provider, and what steps did you have to take to get networking to work which appears to be the issue?
Homestead.yaml
ip: 192.168.10.10
memory: 2048
cpus: 1
provider: hyperv
authorize: ~/.ssh/example/id_rsa.pub
keys:
- ~/.ssh/example/id_rsa
folders:
-
map: 'D:\Projects\example\server'
to: /home/vagrant/server
sites:
-
map: server.app
to: /home/vagrant/server/public
databases:
- example
name: example
hostname: example
Vagrant Up
Bringing machine 'example' up with 'hyperv' provider...
==> example: Verifying Hyper-V is enabled...
==> example: Importing a Hyper-V instance
example: Please choose a switch to attach to your Hyper-V instance.
example: If none of these are appropriate, please open the Hyper-V manager
example: to create a new virtual switch.
example:
example: 1) DockerNAT
example: 2) Default Switch
example: 3) NewInternalVirtualSwitch
example:
example: What switch would you like to use? 3
example: Cloning virtual hard drive...
example: Creating and registering the VM...
example: Setting VM Integration Services
example: Successfully imported a VM with name: ubuntu-16.04-amd64_1
==> example: Starting the machine...
==> example: Waiting for the machine to report its IP address...
example: Timeout: 120 seconds
example: IP: fe80::215:5dff:fe38:107
==> example: Waiting for machine to boot. This may take a few minutes...
example: SSH address: fe80::215:5dff:fe38:107:22
example: SSH username: vagrant
example: SSH auth method: private key <--- Stalls out for a couple minutes
Error
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
Update
Also tried tip 4 using an external virtual switch and it makes it further, but still fails with an error while trying to assign a hostname:
==> example: Machine booted and ready!
==> example: Setting hostname...
No host IP was given to the Vagrant core NFS helper. This is
an internal error that should be reported as a bug.
Edit: After setting it all up and testing workflow, I went back to VirtualBox + Homestead and disabled Hyper V. The bottom line is that Windows and Linux are not very compatible with each other and while Hyper V is native to Windows, everything that follows won't be and even simple tasks like copying files and setting permissions require a lot of labor.
I will leave my answer below, maybe someone else or I will come back to it in the future.
I just spent a day trying to get it to work and I couldn't but I came up with a solution that works better for me at least so I'll share it here.
If your workstation runs Windows 10 Pro with Hyper V and you know how to set up your production server, then it might work for you.
The idea is to give up on Homestead and set up your local server just like you do the production server but on Hyper V:
Enable Hyper V
Download your server OS image (Ubuntu 18.04 for me) and create a virtual machine with it.
Choose what you need from the list of software included in homestead and install those on the virtual machine (for me its Nginx, PHP, PostgreSQL, Git, Python, and Composer).
At this point you pretty much have your custom made Homestead on Hyper V. Log into the virtual machine, copy its ip (it should show it upon login but if not, here is a command to bring it up on Ubuntu ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'), enter it into the browser window and it should bring the default Nginx frontpage up.
It's pretty easy, but the problem is that this ip is dynamic and it will keep resetting. The toughest part is to make it static.
Set ip in the Hyper-V manager to static right click the virtual machine -> Settings -> Network Adapter -> Advanced Features. Reboot everything
Set ip to static in the OS in virtual machine (guide for Ubuntu 18.04). Note that ip address of the host Hyper V vEthernet adapter (ipconfig on Win 10 to bring it up) is the gateway address for the virtual machine OS.
So pros and cons from my perspective.
Pros:
Works faster and cleaner on Windows + Hyper V than on Windows + Oracle Virtual Box
Customizable and updatable. The only way to update Homestead seems to be delete it and download the new one.
Cons:
Hard to set up if you are not familiar with your production server setup
Setting up static IP is really a painful lot of hacking
Accessing files between Linux and Windows requires Samba dependency
Managing permissions of Linux files accessed through Windows is complicated
Linux guest doesn't seem to have access to GPU through Hyper V
This problem may happen because by default, the Hyper-V switches are treated as Public network; the Windows firewall blocks access to virtual machines.
One easy but dangerous workaround is to simply turn off the Windows firewall. You can do that to test whether this is your problem, but of course do not leave the firewall off.
A better solution is to disable the firewall only for the network switch (or switches). This cannot be done in the GUI; you need an elevated PowerShell for that.
set-NetFirewallProfile -DisabledInterfaceAliases NewInternalVirtualSwitch,DockerNAT,Default
Note that if you want to disable the firewall for multiple switches, you must specify all of them in a single call to Set-NetFirewallProfile.
An even better solution would be to change the switches to private network, but I am not aware of any way to do that.
Had similar issues here (on Windows 10 Home) trying to run Docker along side Homestead. I can't say for sure what did the trick but I ended up with this:
In Windows features turn on:
Virtual Machine Platform
Windows Hypervisor Platform
Windows Subsystem for Linux
Used HyperVSwitch to turn on even more Hyper-V (just turning it on as a "Windows feature" is not enough!) https://unclassified.software/en/apps/hypervswitch
Restart Windows
In the VirtualBox manager disabled "Adapter 2" for the Homestead machine (Settings > Network > Adapter 2 > uncheck Enable Network Adapter)
Run the Homestead machine as normally.
Adapter 2 will be turned on again once you restart the Homestead machine But it seams that it now works fine in combination with all the Hyper-V settings.
Since it was a lot of trail, error and restarting of servers I'm not sure what exactly did the trick but I hope it helps some people in their quest to run Docker and Homestead together.
I know now at least that it's possible :)

Access IIS Express running on virtual machine

I'm trying to access IIS Express that I have running on a windows virtual machine on my mac. I have tried including an additional binding pointing to the IP of the virtual machine, ive used netsh to allow a url reservation and made sure that the firewalls are not enabled.
After all of this I attempted to run a program in visual studio and access it via the url on my Mac. The page idles for a large amount of time before returning the error that there was "No Route Host"
This is driving me crazy! Does anyone have any suggestions as to what could be causing it?
Do the following:
Open IIS, and check whether your HTTP website is running on port 80.
Ensure above by first browsing your website on windows guest itself.
Check connectivity by sending ping from your MAC host to windows guest IP.
If above succeeds, perform telnet on port number 80 from MAC host.
You must be able to crack your issue at one of the above points.

Are there any alternatives to hosts file for accessing virtual hosts from multiple PCs?

I have several virtual hosts set up on my PC running WAMP. All the other PCs in the office need to be able to access these too. Traditionally, every time I added a new virtual host to my PC, I need to go to all of the other office PCs and modify their hosts files. This works fine, but it is a pain to go edit all of these files.
Is there an alternative to this? Is there some way of having a centralised hosts file on the network or some other solution?
Some routers have the ability to map domain records into IP adresses and act like a DNS. But if your router dont support this:
Try Acrylic DNS Proxy. Acrylic is a free and open source local DNS proxy. Follow the installation instructions on the website to set it up. Basicly you will need to install this program only on your main PC that will act like a "DNS proxy". Then you will need to set your other computers primary DNS server to hook with your main pc.
Step 1: Install
Launch the Acrylic.exe file and click on the Next button.
Read and (if you like it) accept the license agreement by clicking on the I Agree button.
Choose the installation folder (the default is the Program Files\Acrylic DNS Proxy folder) and click on the Install button.
Step 2: Configure
Do the following steps only on your main PC
Click on Start Menu -> Programs -> Acrylic DNS Proxy -> Config -> Edit Configuration File
Find the text "; ALLOWING REQUESTS FROM OTHER COMPUTERS" and configure it properly. Its well commented and very easy.
Click on Start Menu -> Programs -> Acrylic DNS Proxy -> Config -> Edit Custom Hosts File
Edit the host file as you want. You can use Wildcards like "192.168.0.2 *.local" or regular expressions. So all the domains ending with ".local" will be pointed to your main server.
Note: After changing the configuration files you must restart the Acrylic DNS Proxy service from the start menu.
Step 3: Hook to the DNS Proxy
In order to use Acrylic you have to tell your computer that the DNS servers to be contacted for name resolution is no more your ISP's but Acrylic. There are ways to do it depending on the version of the OS you are running:
Windows 2000
Windows XP or Windows Server 2003
Windows Vista or Windows 7 or Windows Server 2008
Note: On your other computers you will have to replace the "127.0.0.1" to your main PC network address. For example "192.168.0.2" . And leave the secondary DNS to 8.8.8.8 (Google DNS) so the other computers can browse the internet even when your main PC is not connectable (or turned off). Like this
Step 4: Test
Make sure everything is properly configured and your main PC is connectable and running. If you have antivirus or firewall programs they will block this DNS proxy so make sure you configure them properly or disable them at first just to test everything is working. Also your main PC local IP address must be static.

Getting Visual Studio debugging to work when running in Parallels

I've got a Windows 7 machine set up on Paralells.
Everything is working fine. Can access internet from IE or other browsers on my Parallels.
However, when trying to debug a web application in Visual Studio 2010 (by pressing F5 for example) then my default browser in OSX launches, which is great, with localhost:4243 (or whatever port Cassini has allocated on my vm)
Naturally, this doesn't find anything...
What do I need to do to either my parallels vm, or the settings on OSX to get debugging working? ie- my mac talking to the vm?
Make sure you are on the same network.
Use IIS.
Like so:
Your Win-machine has a name, let's say it's called "myWin7machine". Change "localhost:4243" to "myWin7machine:4243" in the browser.
If this doesn't work (well... it shouldn't) you might have the firewall on or the network not bridged. Let's start with the bridging.
Time to check some basics - be on the same network
Check your IP address. It's "ipconfig" on the Win machine and "ifconfig" on the mac; both run from the command prompt. The IP address should be something like 10.4.... or 192.168... on both. The important thing is that only the last number is different. (this is technically not correct but works for 99% of the cases) If they are equal (except the last) you are bridged - which means both machines are on the same network. If they differ too much you had running the Win machine's network "inside" the Mac's. Go to the settings for Parallels (in windows: move your mouse to the top to show Parallel's menu and go to Devices->Network and something "(bridged)". Wait until the balloons disappear and check ipconfig again.
Check that you can ping the Win machine from the Mac. Ping functionality might be turned off in the Win machine but probably isn't.
Now we know we are on the same network.
Still doesn't work
Can you do http://myWin7machine:4243 from the mac? Well.. you shouldn't be able to.
Can you do it from the Win machine? You should.
IIRC Cassini doesn't talk to strangers. I.e. it doesn't talk to anything but localhost.
If I am wrong - just open port 4243 in the firewall on the win machine and you should be good to go.
But otherwise...
Time to change web server.
Install IIS on the win machine.
In the Mac: surf to http://myWin7machine and see the IIS7 logo show.
If you don't you have a firewall issue. Open port 80. Try again.
If you have come this far then you can surf from the Mac to the IIS on the Win machine.
Time to set up your VS solution
Open the IIS admin GUI. Create a new Site. Let's say you call it MyTestSite. (you can always rename it later) Point it to your VS solution's web. Typically the same folder as web.config resides in. On the win machine: try surfing to "http://localhost/MyTestSite". Your site should show up. You might get an Apppool error.
Now try http://myWin7machine/MyTestSite on the Mac. It should work.
ROCK!
Time to set up debugging in VS
For debugging in IIS you have to connect to the process. In Win7 it requires elevated privileges so either you restart VS as admin or you try to connect and VS will do it for you.
The menu in VS is Debug->Attach to process and you choose w3wp.exe.
This is how you debug faster anyway - by connecting. Restarting your web for every debugging session is a waste of time.
To make connecting faster - use ctrl-alt-p and the continue with using the keyboard.
To make connecting even faster use a macro.
There is more info in these 4 articles: http://www.selfelected.com/tag/iis/
Set a breakpoint. Refresh your browser and the breakpoint should be hit.
Time to hack some code
Good luck!
I'm using Windows 10, VS 2015, Parallels 11 on iMac with OS X El Capitan (10.11.5). The following are the steps that worked for me:
On Windows side:
Get the IP (run ipconfig command in command window)
Get the host name (run hostname command in command window)
In control panel look for Windows Firewall -> Advanced Settings and add a new inbound rule and a new outbound rule. For both make sure you select Port, Allow Connection, TCP and specific IPs. I added a range of IPs 45000 - 45999 but you can select the range you like.
In Visual Studio:
Look for project properties and under web section change Server settings to look something like this.
Instead of "winmac" you will use the host name found in "Windows Side - Step 2". The port can be any number inside the range you setup for your firewall rules.
On Mac OS side:
Update /etc/hosts file. At the end of the file add the IP and host name that we found on steps 1 and 2 of the "Windows side" section. When you finish this step the file should like something similar to this.
Ready to debug:
Now you can start debugging in your Mac from Visual Studio. Make sure that before start the debugging process you select "Open In Mac" option (instead of Chrome or IE in your debugging options in visual studio).

Resources