Posted on 03/07/2012. By Pete Otaqui.
I think I’m not the only one who’s caused themselves headaches on their main working computer by either using an off-the-shelf server stack like MAMP, or by manually installing the parts you need to develop dynamic websites.
Since I worked at the BBC, and specifically on the Forge platform, I’ve become completely convinced by developing on a local virtual machine, which runs whatever OS you are deploying to. This immediately resolves all sorts of issues, completely freeing you from ever worrying about the differences between Mac / Windows / RedHat / Debian / etc.
You also get other benefits like really easy snapshots of your setup, the ability to create very heavily customised setups without any side effects on the rest of your system, and so on. It’s also replicable, so you can give other developers a copy of your whole platform very simply.
The next from here is using something Chef to manage your environment provisioning, but that’s probably still not streamlined enough for the average developer to sort out themselves.
So – my advice is that all web developers would almost certainly benefit from downloading VirtualBox and creating themselves a VM-per-deployment-target. Here are some other hints:
- In VirtualBox, you will probably want to set up 2 network interfaces, NAT so the vm can see out onto the internet, and INTERNAL so the host can see into the vm
- You can enjoy the magic of dhcp, and still get to your vm via a hostname by editing the hosts file on your host machine
- If you want the vm to be easily portable across flash drives (or anything formatted as FAT32) you should create a VMDK disk and split it into 2GB files
- You will almost certainly want to share your code directory to the VM, and assuming you are using a linux guest, you will be better off doing this via editing the “/etc/fstab” rather than Virtualbox’s auto mounting. Create the share, make it permanent, create the directory on your vm that you want to map, and then add an entry to /etc/fstab. Check out the VBox manual for more info on correct values and uid and gid options.
- If you do go for the shared folder bit with a linux guest, be aware that by default shared folders in VBox cannot create symlinks! You will get all sorts of silly warnings about read only filesystems and the like – check out my post about it .