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 a...
What can Vagrant do for me?● Easily create environments without waiting  for an Operating system install● Easily configure...
Lets get startedInstall VirtualboxInstall Vagrant (Windows users may need to restart after)Start an admin command lineente...
Create a project foldermkdir vagrant-memphisphpcd vagrant-memphisphpvagrant initA file Vagrantfile is created, edit this f...
Configure network / portsuncomment the config.vm.network line and letsset up port 9000 to forward to port 80 on theVMconfi...
Fire up the VM!Simply run vagrant upOnce the command has finished, the box willbe running in the background.Now we need to...
SSH + Windows = Putty+ PuttyGenOn windows, this will give a warning that it cannot find anexecutable ssh. What we need to ...
Lamp Config! - http://pastebin.com/dFtidcrF#!/bin/bashrpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-rele...
Post Lamp config...Once this script completes you should be ableto view http://localhost:9000/ and see thedefault CentOS a...
Shared FoldersBy default vagrant shares the project directorywith the guest VM mounted at /vagrant You canadd your own sha...
Shutting Down / ReloadingWhen you need to shut down or halt the VMyou can simply use vagrant halt.If you need to restart t...
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 t...
Links & Further ReadingVagrant: www.vagrantup.comVagrant Boxen:www.vagrantbox.esCentOS: www.centos.org
Upcoming SlideShare
Loading in …5
×

Quick & Easy Dev Environments with Vagrant

1,246
-1

Published on

MemphisPHP.org

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,246
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Quick & Easy Dev Environments with Vagrant

  1. 1. Quick & Easy Dev Environments with Vagrant MemphisPHP.org 3/26/13 Tonights Sponsor:
  2. 2. 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
  3. 3. 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
  4. 4. 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
  5. 5. 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.
  6. 6. 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
  7. 7. 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
  8. 8. 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
  9. 9. 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
  10. 10. Post Lamp config...Once this script completes you should be ableto view http://localhost:9000/ and see thedefault CentOS apache page.
  11. 11. Shared FoldersBy default vagrant shares the project directorywith the guest VM mounted at /vagrant You canadd your own shares via the Vagrantfile.
  12. 12. 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.
  13. 13. Destroy!To completely wipe the VM you can vagrantdestroy.Then simply run vagrant up again to reimportthe box and start over.
  14. 14. 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
  15. 15. Links & Further ReadingVagrant: www.vagrantup.comVagrant Boxen:www.vagrantbox.esCentOS: www.centos.org
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×