Dev ENVIRONMENTS
Or "How I Learned to Stop Fighting and use Vagrant"
By
Who Am I?
- BA in Digital Media from UCF
- 4+ years of Web Development XP
- Currently a Techranger at UCF's Center for Distributed Learning (Part of the New Media team too!)
Quit some bad habits
But why?
- "Processed Foods"
- Different environment builds
- "If you give a man a fish..."
What about built in options?
Built in dev servers were added in PHP 5.4
$ php -S localhost:8000
Even have it for Python and RoR
$ python manage.py runserver
$ rails server
Mo' Options, Mo' Problems
These won't solve our problem:
- PHP isn't going to work with anything Apache (.htaccess anyone?)
- Can't program any other languages
- NOT THE SAME ENVIRONMENT AS PRODUCTION
What We need
An option that's as easy or as complicated as you want it to be, while being able to mimic your production environment.
What Vagrant IS
Vagrant is a way to configure and save virtual machine builds so everyone has the same dependencies without having to configure everything all the time.
What you absolutely need
-
Ruby (Vagrant is written in this)
-
A Virtual Machine environment
-
Vagrant itself
Basic workflow
$ vagrant box add base http://files.vagrantup.com/precise64.box
$ vagrant init
$ vagrant up
That's it!
Vagrant File
$ vagrant init
- Produces a file called Vagrantfile in the current directory
Getting into your Vagrant Box
Building a LAMP stack
$ sudo apt-get update
$ sudo apt-get install apache2
$ sudo apt-get install php5 libapache2-mod-php5
$ sudo apt-get install mysql-server
$ sudo apt-get install phpmyadmin
$ sudo service apache2 restart
- Don't forget any other dependencies you need (git, composer, etc)
Plugins allow you to add extra functionality to Vagrant that might not come standard.
- Domain resolution on your local machine
- New providers
- New provisioners
- And more!