Dev partitions with vagrant.

Partitioning a developer environment from the standard operating system makes things a lot cleaner when developing anything. Enter Vagrant. Vagrant is not stand alone, it works in tandem with Virtual Box to create environments for application/web development.

I discovered Vagrant during my Udacity coursework, they use it in the coursework because it makes the need for a specific operating system irrelevant. Vagrant is a program that works in tandem with Virtual box and sets up a headless (no graphical interface) environment. You can SSH into this environment which is separate and doesn’t affect anything directly in your own environment.

Why would I even use something like this? It allows you to configure an operating system without any fear of wrecking the configurations on your own host operating system.

Where Vagrant is really useful is for development on a Windows machine. Lots of people develop on Macs now and macs of any kind are relatively expensive. Usually on a given PC you can get the equivalent specs for 50% or even less in a standard machine with Windows loaded. What this allows is for you to create an environment with a standard bash shell that you can work in tandem with an IDE from JetBrains, anyone of their IDES. Unfortunately a text editor might not work so well.

VirtualBox_Logo.png

You are not limited to anyone environment, try out several. Below I have a list of all of my dev boxes:

vagrant_boxes.PNG

A vagrant box will act like any standard linux distro you use, the added bonus is the ability to get preconfigured boxes.

Vagrant_boxes_.PNG

With Virtual Box and Vagrant installed, installing a box in a given directory is as simple as something like “vagrant init ubuntu/trusty64” followed by “vagrant up.” You can then SSH into your machine.

ssh_vagrant_example.PNG

I’ve gone this far with you, let’s go a little further. You want to do a little web development.

I’m going to switch over to a Vagrant box made by scotch.io, Scotch box.

I’ll do exactly what I did previously in the last example. Scotch is preconfigured to view at “192.168.33.10” in your browser. You can look at the Vagrantfile to see for yourself.

scotchbox_logo.PNG

The folder the Vagrantfile is in is the synced folder between the guest and host machine. You can do dev on here but typically the web directory will be at /var/www/html/.

The nice thing about scotchbox is they make the web directory labeled “public” synced in the box folder.

making_html_file_scotch_box.PNG

success_html.PNG

In summary using Vagrant is a way to set up several different kinds of development environments without the worry of using WAMP or MAMP anymore. Mamp doesn’t really allow for mulitple instances to be installed, with Vagrant you can do that. Granted it is a little more technical and one needs to usually work with files through connecting into the machine, but it’s worth it. Take a little time to learn it and it’ll outweigh all the advantages of standard LAMP development of an Apple machine.

There are alternatives to using Vagrant. You can setup a remote environment with a service like digital ocean, a raspberry pi (though if anything goes haywire you’ll have to reinstall the OS on the SD card), and Docker (something I don’t have much experience with currently).

P.S. I own several Apple products: iPhone, iPad, iMac, and Air; I’m just justifying a valid point in the article when I state standard development practices are even on any machine using Vagrant. (:

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *