Slide 1

Slide 1 text

Christoph Lühr @chluehr / @bephpug 2013 "Rags to Riches" Vagrant for PHP

Slide 2

Slide 2 text

basilicom

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Image source: http://www.flickr.com/photos/stinajonsson/3932774410 CC BY-NC 2.0

Slide 5

Slide 5 text

"Create and configure lightweight, reproducible, and portable development environments."

Slide 6

Slide 6 text

"Infrastructure as Code" - FTW!

Slide 7

Slide 7 text

Development

Slide 8

Slide 8 text

Own Workstation (LAMP, XAMP, MAMP, ...)

Slide 9

Slide 9 text

Shared System (Linux Dev. Box in LAN)

Slide 10

Slide 10 text

Virtual Machine (VMware, VirtualBox, ...)

Slide 11

Slide 11 text

Problems! ● OSX / Windows / Linux ● 32 / 64 bit ● Conflicts! ● Docs / Setup ● Versions / Dependencies ● ⇒ "Works on my box!"

Slide 12

Slide 12 text

Vagrant && Virtual Box

Slide 13

Slide 13 text

apt-get install \ vagrant (Packages for Windows, OSX, too)

Slide 14

Slide 14 text

Vagrantfile (Ruby)

Slide 15

Slide 15 text

Vagrant::Config.run do |config| # Base Box Name config.vm.box = "precise64" # Base Box URL config.vm.box_url = ↵ "http://files.vagrantup.com/precise64.box" # Configure / Install Packages, Application config.vm.provision :shell, ↵ :path => "setup.sh" end

Slide 16

Slide 16 text

setup.sh (bash / shell)

Slide 17

Slide 17 text

#!/bin/bash apt-get update apt-get install libapache2-mod-php5 apt-get install php5-mysql echo "date.timezone = Europe/Berlin" >> /etc/php5/conf.d/date.ini service apache2 restart

Slide 18

Slide 18 text

vagrant command

Slide 19

Slide 19 text

Demo

Slide 20

Slide 20 text

vagrant up 1. Downloads Base Box Image 2. Creates VM from Base Box 3. Configures VM Guest 4. Boots VM 5. Installs / Configures Packages .

Slide 21

Slide 21 text

$ vagrant up [default] Importing base box 'precise64'... [default] Matching MAC address for NAT networking... [default] Clearing any previously set forwarded ports... [default] Forwarding ports... [default] -- 22 => 2222 (adapter 1) [default] -- 80 => 8080 (adapter 1) [default] Creating shared folders metadata... [default] Clearing any previously set network interfaces... [default] Running any VM customizations... [default] Booting VM... [default] Waiting for VM to boot. This can take a few minutes. [default] VM booted and ready for use! [default] Mounting shared folders... [default] -- v-root: /var/www [default] Running provisioner: Vagrant::Provisioners::Shell... stdin: is not a tty ==== BEGIN: Vagrant-setup.sh ====

Slide 22

Slide 22 text

vagrant command up halt reload destroy ...

Slide 23

Slide 23 text

Features! Image source: http://www.flickr.com/photos/rietje/76566707/ CC BY 2.0

Slide 24

Slide 24 text

Multiple-VMs (Apache / DB-Master / DB-Slave)

Slide 25

Slide 25 text

VMware, AWS EC2, ... (Providers / Platforms)

Slide 26

Slide 26 text

Puppet / Chef (Different Installers/Provisioners)

Slide 27

Slide 27 text

Custom Base Boxes (Speed up Setup)

Slide 28

Slide 28 text

Drawbacks

Slide 29

Slide 29 text

Slow File System (vboxsf, NFS, CIFS, ... SSD!)

Slide 30

Slide 30 text

RAM

Slide 31

Slide 31 text

"Rags to Riches" Success Story!

Slide 32

Slide 32 text

Documented, Repeatable Stable Process, mirrors Live-System

Slide 33

Slide 33 text

Development Speed++ (Setup, new Colleagues, less fiddling)

Slide 34

Slide 34 text

Open Source Projects Benefits: easier evaluation / collaboration

Slide 35

Slide 35 text

1. git clone 2. vagrant up 3. ... 4. Profit!

Slide 36

Slide 36 text

Contact Christoph Lühr eMail: [email protected], [email protected] Twitter: @chluehr Slides license Attribution-NonCommercial-ShareAlike 3.0 http://creativecommons.org/licenses/by-nc-sa/3.0/ Thanks! Questions?

Slide 37

Slide 37 text

Links ● Vagrant http://www.vagrantup.com/ ● Roundcube Fork with Vagrantfile https://github.com/chluehr/roundcubemail