How to use Ubuntu Server as web server on Windows 7 or Mac OS X via VirtualBox
Working with Drupal and trying to get as close as possible to the production environment has moved my development from Windows & Mac to Ubuntu. Recently I found that I spend some 70% of time using Ubuntu VM, and rest of the time on PC/Mac. First (long time ago) I used my own Virtual Machines, but after some time I found great Drupal project named Quickstart. Later, there was second one named DrupalPro.
Both of them are great. Inside VM (hosted by Virtual Box) I have full development environment and practically everything that I need (apache, drush, mysql, netbeans, (just to mention few).
But there is small problem. As long as I work on project by myself, everything is OK. But there is always time that I need to move that VM to another machine for presentation purpose, or work just require compatibility reviews in other browser like IE, or Safari. First presentation. For that I need laptop that mimics my dev env (CPU, monitors, RAM…). Second is reviewing outside my VM. It is easy to select Bridged adapter inside VM settings, but adding site name to the corporate DNS is little tricky and sometimes impossible in early project stages. Finally I found that some tools are either better or at least looking better on Windows or Mac.
So solution is to have “headless” Ubuntu server (step closer to prod) that will act as local one on my host OS. In that way I can easily review my work outside Linux, get fast VM transfer to another host, and I’m now able to use other development tools. Finally I’m doing all of this because I do not want to install WAMP or MAMP stack on my Win/Mac machines.
The solution has two parts.
Allow Ubuntu server (guest) to be accessible via browser in host.
Use shared folders so that Ubuntu server (guest) can access those files.
Allow Ubuntu server (guest) to be accessible via your browser in host
Add new rule in the same NAT.
First select the vm inside virtual box and go to settings > network > port forwarding
Add the rule with host port as 3022 and guest port as 22 and the name as ssh.
Leave everything else as blank.
Add second rule called web. Host port is 8888 or anything that is larger than 1024. Guest port is 80.
Reboot VM and try http://localhost:8888 and you should see web site fully functioning.
Use shared folders
How to do this part I already blogged and you can find solution here:
ps. I'm preparing text that will describe step-by-step how to build VM server for Drupal development and how to link it with tools installed on host OS.