Starting a new Magento project (or any framework backed project) can involve tedious tasks before you even begin coding. Download the latest Magento version, extract, configure a database, update the application config etc… It can take quite a while to get going.
What if you could run a few simple commands to automate the above steps?
What if you could automatically configure a development environment using a virtual machine to closely emulate a production environment?
With Vagrant, both of the above are possible (and a whole lot more).
What is Vagrant?
In very simple terms, Vagrant works alongside Virtualbox to allow simple provisioning of a virtualised server, tailored specifically to your project. In fact, Vagrant provisioner configuration scripts used to build your development machine can be committed with to your project’s repo. This allows other developers to get to work on your project using an identical and predictable dev box to test their code.
For me, Vagrant’s killer feature is the fact that the configuration of each box is completely autonomous. This allows you to tailor a development box to your exact requirements for a single project, without affecting any other projects or your local machine. In contrast, installing a web server directly on your local machine would usually require global configuration options, modules and messing with ports and local DNS configuration. Vagrant boxes and provisioners are clean, non-destructive and easily removed leaving your development machine just as it was before.
A Simple Magento Development Environment
To get started, I have put together a simple shell script provisioner for getting a Magento installation running on a Ubuntu virtual box. This automates the following steps:
- Download a bare Ubuntu “Box” (Precise 64bit 12.04)
- Install PHP 5.3, MySQL 5.5, Apache 2.2
- Configure an Apache virtualhost file and web directory
- Create a database and database user for Magento
- Download Magento (CE 18.104.22.168) from the official site
- Extract Magento into the web root directory and set appropriate folder permissions
- Run Magento’s PHP/command line install script
- Bridge the virtual machine’s network to allow access from host machine (i.e. your web browser)
Check out my provisioner project on Github. It’s deliberately very simple and unopinionated, leaving plenty of scope for you to tailor the configuration to your specific requirements. It’s perfect for getting from naught-to-magento in a couple of minutes allowing you to get coding as soon as possible.