Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Local WordPress Development Using Vagrant

Local WordPress Development Using Vagrant

William Whitehead

July 26, 2016
Tweet

Other Decks in Programming

Transcript

  1. VAGRANT INTRO WHAT IS VAGRANT? ▸ Command line interface to

    manage virtual development environments. Build a development environment that matches your production environment.
  2. VAGRANT INTRO WHY USE VAGRANT? ▸ It’s free, cross-platform ▸

    Easy to install, trusted by lots of organizations like the BBC, Expedia, Mozilla ▸ Build your own “box” or use one of the many available “boxes”
  3. VAGRANT INTRO WHY SHOULDN'T YOU USE VAGRANT? ▸ Takes awhile

    to import your box the first time it is used ▸ “Boxes” take up a considerable amount of hard disk space ▸ Using the WordPress admin in a virtual environment can be slow if your computer is kinda slow
  4. USING VAGRANT GETTING STARTED ▸ Download + install Vagrant ▸

    Download + install VirtualBox ▸ Download a “box” from the Vagrant repo or…
  5. USING VAGRANT CLONE SCOTCH BOX & WPDISTILLERY USING GIT! ▸

    “Scotch Box” is a Vagrant box configured for PHP development ▸ “WPDistillery” is a configuration file and shell script to get your “Scotch Box” setup for WordPress development
 
 ⁃ Clone Scotch Box and WPDistillery from the command line
 ⁃ Open up and edit the config.yml file
  6. USING VAGRANT VAGRANT UP ▸ Running “vagrant up” from the

    command line in your project directory launches your virtual machine ▸ Behind the scenes, Vagrant is communicating with VirtualBox to boot up your virtual machine ▸ Once we finish configuration, running “vagrant up” from your project directory will be all you need to access your development site in the web browser
  7. USING VAGRANT VAGRANT SSH ▸ After “vagrant up” finishes, you

    can SSH into your “box” via “vagrant ssh,” giving you command line access to your development environment ▸ Update WP-CLI + execute the the WPDistillery shell script ▸ Now WordPress is setup and ready to go!
  8. USING VAGRANT UPDATE HOSTS FILE ▸ Let’s update our hosts

    file so we can browse our site at a URL we specify (instead of something like http:// 192.168.33.10/)
  9. USING VAGRANT OTHER USEFUL COMMANDS ▸ vagrant halt - shuts

    down your machine ▸ vagrant destroy - deletes your machine (including the box) ▸ vagrant share - share your development site with anyone that has your Vagrant generated URL (need to install the ‘Relative URL’ plugin — https://wordpress.org/plugins/ relative-url/)
  10. WP-CLI BONUS! WP-CLI ▸ WordPress Command-Line Interface: execute WordPress commands

    from the command-line ▸ Update core: wp core update && wp core update-db ▸ Backup your database: wp db export backup.sql ▸ Generate some dummy posts: wp post generate --count=100 ▸ Import media in bulk: wp media import images_folder/* ▸ Search + Replace: wp search-replace 'dev.example.com' 'www.example.com'