Sammy Mwamburi

Using Vagrant

While developing, you might need to create a local environment that matches your production server more closely. And if you’re on Windows (or Mac) and your server is on a Linux distribution, it’ll be cumbersome troubelshooting OS specific bugs and errors. There are a multiple variations of the virtual machine concept in the market; Docker, VirtualBox and VMWare, but Vagrant offers a scaled down, light version of the actual operating system known as boxes. These are capable of all essential functionality without the additional bulk or GUI, making it much faster and very efficient. This is extremely beneficial especially when running resource-hungry platforms such as Hadoop from your VM.

In this tutorial we will set up Vagrant with Ubuntu 12 on Windows and install an Apache, MySQL and PHP (LAMP) server in the Ubuntu VM. This will create a PHP programming environment in your Virtual Machine. Phalcon PHP already has a pre-configured box on Vagrant but for the purpose of learning we will install each component individually.

a. Install VirtualBox

b. Install Vagrant

c. Install Ubuntu VM

d. Install LAMP on Ubuntu VM LAMP (Linux, Apache, MySQL and PHP)

e. View the server in a browser

f. In conclusion These are the Vagrant commands you’ll need to know: vagrant box add [ORG/BUILD] - Add a new VM
vagrant init [ORG/BUILD] - Initialize VM vagrant up - Boot VM vagrant reload - Restart VM vagrant halt - Shut down VM exit - Quit Vagrant

Boxes are available online here from providers

Lastly, note that all the commands must be done locally from the directory in which you want or have the virtual machine installed.