I’ve used MAMP to develop websites locally for a while now. MAMP is convenient for a number of reasons.
- It’s simple to setup
- Requires little maintenance
- Reliable and widely supported
But it has its flaws. For example, if you update OS X, MAMP could potentially have errors that prevent you from your work. Since MAMP turns your Mac into a server, you could run into collisions like this.
Virtualizing a development environment
If one of the problems with MAMP is colliding with your OS X install, what if there was a way to separate the two? What if you virtualized your environment so one never interfered with the other?
This is where Vagrant comes in. Vagrant is a command line tool that allows you to quickly fire up a virtualized server (usually running Ubuntu, Debian or CentOS). It builds the server based on the settings in a Vagrantfile. This file stores the configuration of the environment so it can be created (and destroyed) with few commands.
What makes Vagrant so much better than MAMP?
While MAMP is still a great application, here’s a couple reasons why you might want to use Vagrant:
It can be configured to mirror your production environment.
MAMP may not be configured the same way your production server is. This could be a problem if you build out a feature that works locally, but because your PHP version is different it fails in production. Vagrant can easily be configured to give you a 1-to-1 mirror of your production environment.
You can version control your development environment.
I forked a great LAMP-stack Vagrant project and made a couple tweaks to it that fits my workflow. Because my Vagrant setup is on GitHub I could jump on another computer, Install Vagrant and run the following commands to build my development environment:
Just these commands will bootstrap a server that includes:
- zsh with oh-my-zsh
- git, subversion
- Virtualhost management
- and much more
Feeling brave? Try it out!
If you are curious about Vagrant, you can try out my project fork.