Before I get started, none of what you are about read is necessary if you can setup a bridged network with VirtualBox. The reason I had to do all of this is because I’m on a Macbook Air connecting to the network wirelessly. For some reason, bridged networking with VirtualBox on a Mac using wireless Internet connectivity doesn’t always work. Sometimes it does. Sometimes it doesn’t. So this is what I did.
I got tired of managing my web development stack on my Mac. It especially became a problem with El Capitan. Until El Capitan, I was reasonably happy using MAMP, but then El Capitan came out and dicked up a bunch of stuff with Open SSL. MAMP runs and old version of Open SSL and now Apple has it’s own implementation. Anyway, it became a headache to keep messing with running Apache, MySQL and PHP on my Mac – again.
So instead of cobbling together another solution, I was thinking about using brew, I decided to say, “Screw this, I’m must going to run Linux in a VM and be done with it.”
So I setup Ubuntu in VirtualBox and set out to solve how to integrate that LAMP stack into my Eclipse development environment on my Mac.
Here are just some notes I made that might help someone else, or myself when I have to do this again.
Connecting to the VM
Since bridged networking didn’t work for me, I had to use VirtualBox port forwarding to access the Ubuntu VM. I mapped 9999 to 80 for Apache. I mapped 9906 to 3306 for MySQL. I mapped 2222 to 22 for SSH.
For MySQL, you have to allow TCP connections, disabled by default. To do that enter a bind-address in your /etc/mysql/my.cnf on the Ubuntu VM. It should be 10.0.2.15, the VM’s private IP address.
If you have to access resources on a VPN from the VM, just connect with the host VPN client and VirtualBox’s NAT will take care of it. You can configure the VM to make a VPN connection as well, but I’ve found that to be unnecessary.