• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Quick & Easy Dev Environments with Vagrant
 

Quick & Easy Dev Environments with Vagrant

on

  • 1,098 views

MemphisPHP.org

MemphisPHP.org

Statistics

Views

Total Views
1,098
Views on SlideShare
1,096
Embed Views
2

Actions

Likes
0
Downloads
3
Comments
0

1 Embed 2

https://twitter.com 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Quick & Easy Dev Environments with Vagrant Quick & Easy Dev Environments with Vagrant Presentation Transcript

    • Quick & Easy Dev Environments with Vagrant MemphisPHP.org 3/26/13 Tonights Sponsor:
    • About Vagrant"Vagrant is a tool for building completedevelopment environments. With an easy-to-use workflow and focus on automation, Vagrantlowers development environment setup time,increases development/production parity, andmakes the "works on my machine" excuse arelic of the past."-http://www.vagrantup.com/about.html
    • What can Vagrant do for me?● Easily create environments without waiting for an Operating system install● Easily configure pre-built boxes or build your own● Share packaged environments with coworkers or a team of developers● Ensures everyone is developing against the same target environment.● Portable - move environments from machine to machine
    • Lets get startedInstall VirtualboxInstall Vagrant (Windows users may need to restart after)Start an admin command lineenter vagrant -v in the command line.Aquire a vagrant box http://www.vagrantbox.es/vagrant box add box_name URL/Path
    • Create a project foldermkdir vagrant-memphisphpcd vagrant-memphisphpvagrant initA file Vagrantfile is created, edit this file andchange the value of config.vm.box to the nameof the box you added earlier.
    • Configure network / portsuncomment the config.vm.network line and letsset up port 9000 to forward to port 80 on theVMconfig.vm.network :forwarded_port, guest: 80,host: 9000
    • Fire up the VM!Simply run vagrant upOnce the command has finished, the box willbe running in the background.Now we need to configure ssh so we canremote into the box.vagrant ssh
    • SSH + Windows = Putty+ PuttyGenOn windows, this will give a warning that it cannot find anexecutable ssh. What we need to do here is open putty,configure 127.0.0.1:2222 with the private key it generatedhere: C:/Users/halo/.vagrant.d/insecure_private_keyYou will need to use Puttygen to generate the key for puttyto use. The user name will be vagrant
    • Lamp Config! - http://pastebin.com/dFtidcrF#!/bin/bashrpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpmrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpmyum -y--enablerepo=remi,remi-test install httpd mysql mysql-server php php-commonyum -y--enablerepo=remi,remi-test install php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdochkconfig --levels 235 httpd onchkconfig --levels 235 mysqld on/etc/init.d/httpd start/etc/init.d/mysqld start/usr/bin/mysqladmin -u root password vagrant/usr/bin/mysqladmin -u root -h localhost password vagrantiptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPTiptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 2222 -j ACCEPTiptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 9000 -j ACCEPTservice iptables saveyum -y --enablerepo=remi,remi-test install phpmyadmin git
    • Post Lamp config...Once this script completes you should be ableto view http://localhost:9000/ and see thedefault CentOS apache page.
    • Shared FoldersBy default vagrant shares the project directorywith the guest VM mounted at /vagrant You canadd your own shares via the Vagrantfile.
    • Shutting Down / ReloadingWhen you need to shut down or halt the VMyou can simply use vagrant halt.If you need to restart to reload the Vagrantfileconfig, use vagrant reloadYou can also vagrant suspend to suspend theVM.
    • Destroy!To completely wipe the VM you can vagrantdestroy.Then simply run vagrant up again to reimportthe box and start over.
    • Sharing is caring... or something...vagrant packageThis will shutdown the VM and create adistributable package of the VM to you canshare / deploy to a dev team.C:Usershalovagrant-memphisphp>vagrant package[default] Attempting graceful shutdown of VM...[default] Clearing any previously set forwarded ports...[default] Creating temporary directory for export...[default] Exporting VM...[default] Compressing package to: C:/Users/halo/vagrant-memphisphp/package.box
    • Links & Further ReadingVagrant: www.vagrantup.comVagrant Boxen:www.vagrantbox.esCentOS: www.centos.org