PHP London Meetup December 2012

17
About the Speaker Originally from Cape Town South Africa been living and working in London for 6 years. Developing with PHP on the lamp stack since 2002. Currently work at a well known charity on their scalable fundraising platform. Follow me on twitter @jeremyquinton

description

Using Virtual Box,Vagrant,Chef in your development environment

Transcript of PHP London Meetup December 2012

Page 1: PHP London Meetup December 2012

About the Speaker

• Originally from Cape Town South Africa been living and working in London for 6 years.

• Developing with PHP on the lamp stack since 2002.

• Currently work at a well known charity on their scalable fundraising platform.

• Follow me on twitter @jeremyquinton

Page 2: PHP London Meetup December 2012

Using Vagrant, Virtual Box and Chef in your

Development Environment

Page 3: PHP London Meetup December 2012

The future of Development

@mitchellh creator and maintainer of vagrant

Page 4: PHP London Meetup December 2012

WHY?

“Vagrant lowers development environment setup time, maximize dev/prod parity, and makes the ‘works on my machine’ excuse a relic of the past.” -http://vagrantup.com

http://www.12factor.net

Page 5: PHP London Meetup December 2012
Page 6: PHP London Meetup December 2012

Components of a virtualised development

environment

• Virtualbox - virtualisation layer.

• Vagrant

• Provisioning tool like chef or puppet.

Page 7: PHP London Meetup December 2012

Virtual Box

• Virutalisation product freely available as Open Source Software under (GPL) version 2.

• Supports all major platforms.https://www.virtualbox.org/manual/ch01.html#hostossupport

• Community effort backed by a big company.

• Grab a copy for your platform at https://www.virtualbox.org/wiki/Downloads

Page 8: PHP London Meetup December 2012

Vagrant

• “A tool to transparently manage all the complex parts of modern development within a virtual environment without affecting the everyday workflow of the developer too much.” - vagrantup.com

• Opensource project and written in Ruby, a command line tool. Supported on most major operating systems.

• Hashicorp - http://www.hashicorp.com/blog/announcing-hashicorp.html

• Grab a copy here - http://downloads.vagrantup.com/tags/v1.0.5 for a package or install with ruby gems.

Page 9: PHP London Meetup December 2012

Chef• Chef is a open source provisioning tool which was built for

automating the cloud. https://github.com/opscode/chefhttp://wiki.opscode.com/display/chef/Home

• There are hundreds of recipes which are already written so you can simply re-use them. https://github.com/opscode/cookbooks

• Can be installed via ruby gems. gem install chef

• Different configurations chef solo will be used in the examples.

Page 10: PHP London Meetup December 2012

VCS

Windows Developer

Mac Osx Developer

Linux Developer

ProductionStagingDeployment

tool

VagrantFile

1. vagrant add box box_name package.box2. vagrant up3. vagrant provision

Chef Solo Scripts

Page 11: PHP London Meetup December 2012

How vagrant works

• Vagrant instance is managed with Vagrantfile which is ruby syntax.

• 28 configuration options. You don’t need to use them all I’ll demo 7 today. Full list on vagrantup.com.

Page 12: PHP London Meetup December 2012

Basic VagrantFile

• Vagrant box file can be obtained from 3 places

Page 13: PHP London Meetup December 2012

Three methods to create a box file

Method Pros Cons

Download a box file from http://www.vagrant.es

- Simplest - Up and running quickly

- You don’t know whats on the base box

Using the instructions off vagrantup.com

- Gives understanding of the specifics of a vagrant box setup

- Time consuming. - Miss a step or do a step wrong and you have a vagrant box which has odd behaviour

Using the opensource project VeeWee off github

https://github.com/jedi4ever/veewee

- Simpler,Powerful- Templates for most server operating systems

Page 14: PHP London Meetup December 2012

Vagrant file options

Page 15: PHP London Meetup December 2012

Chef configuration

Page 16: PHP London Meetup December 2012

Demo

• Download Virtualbox 4.1.22http://download.virtualbox.org/virtualbox/4.1.22/

• Download vagrant package or install via ruby gemshttp://downloads.vagrantup.com/tags/v1.0.5

• Add 33.33.33.10 vagrantdemo.com to /etc/hosts

• Get the projectgit clone http://www.github.com/jeremyquinton/vagrant_democd vagrant_demo

• vagrant up --no-provision

• vagrant provision

• Browse to vagrantdemo.com

Page 17: PHP London Meetup December 2012

Sources

•http://downloads.vagrantup.com/tags/v1.0.5

•http://download.virtualbox.org/virtualbox/

•http://www.opscode.com/chef/

•https://github.com/jedi4ever/veewee

•https://github.com/mitchellh/vagrant