Vagrant and WordPress

Guys (and girls).

I’m deleting MAMP from my computer. It’s toast. History. Trash emptied.

You’ve probably heard rumblings around the internet of Vagrant. If you don’t already know, it is a piece of software you can install on your computer to create virtual development environments. It uses something like VirtualBox to easily create virtual servers that you can use for local website development. It’s similar to MAMP but on steroids. I’ve been telling everybody in our Nashville WordPress developer meetups about using Vagrant and I’m hoping to convert a few MAMP users.

You can create as many of these local “servers” as you want, called boxes, which makes it super-useful for mimicking the final destination of your web project. This is great for making sure that your website won’t face-plant when you deploy to your client’s server. The good news is that you can find tons of these vagrant boxes pre-built and ready to go: here and here

I’m not going to do a tutorial on how to set it up because it has been done several times by people smarter than myself. But I will get you pointed in the right direction. If you’re not concerned with the specifics, here’s the tl;dr version.

That’s cool, so where do I start?

Vagrant

When I first started researching, I saw loads of references to the command line and, admittedly, got a little freaked out. But I quickly saw that the great folks at 10up, who I’m pretty sure are hiring, had created their own tool called Varying Vagrant Vagrants (VVV), now an open source project, and hosted it over on GitHub. They also had pretty good instructions in the readme file on how to get up and running: The First Vagrant Up.

It did take me about 30 minutes to setup from start to finish – there’s a lot to download the first time – but overall it was pretty easy. VVV comes pre-loaded with everything you need to start developing on WordPress locally. It even creates entries to your computer’s hosts file so you don’t have to use a local IP address to access sites (127.0.0.1/wp-admin) and can use something sane like mycoolproject.dev.

VVV has four installations of WordPress by default:

Then it also comes with a dashboard for your VVV install that lives at http://vvv.dev/. The dashboard provides links to all of the default WordPress installations as well as links to the built in VVV tools such as phpMyAdmin, phpMemcachedAdmin, Opcache Status, Webgrind, and PHP Info.

Ok. Now what?

Now that you have VVV installed you can stop there if you want and start building a site at local.wordpress.dev. Or you can keep reading and find out how to pimp out your VVV install.

Variable VVV

That’s what I thought.

If you’re like me, you think that just developing one site at a lame local URL is well…lame. It’s totally possible to set up other WordPress installs with the VVV default setup but there’s a tool that makes doing just that SO much easier. Enter Variable VVV (VarVVV) from @bradparbs. Again, there are great instructions for installation on the project’s GitHub page so I won’t go through that process.

With VarVVV you can get a new WordPress installation up and running with vv -c. That’s it. It runs through it’s site creation wizard and allows you to specify several options like:

  • Site title
  • Site directory
  • Domain
  • Version of WordPress
  • Multisite install
  • Debugging options
  • Whether or not you want dummy content
  • Specify a git repo for wp-content

There are a lot of other cool features that I haven’t fully explored. Like being able to setup “Blueprints” which allow you to specify plugins, themes, mu-plugins, options, or constants to be installed on each new site created with VarVVV.

That’s great but that dashboard…

VVV DashboardI know, the default dashboard of VVV leaves a lot to be desired. That’s when I turned to VVV-Dashboard from @leogopal. VVV-Dashboard is much easier on the eyes and it integrates with the VarVVV site creation wizard to keep track of all of your WordPress installations. It also provides links to each admin dashboard and front-end for each site. It maintains the links to the built in VVV tools (phpMyAdmin, etc.) and also lists out some common Vagrant commands.

What else you got?

That’s about it. There are some points I know I didn’t talk about, like how vagrant can be used to standardize local development environments for a team of developers. Again, this is just the way I have it set up and it works great for me. If you think I’ve missed something in this post feel free to tell me in the comments. How are you guys using Vagrant in your process?

TL;DR

2 Replies to “Vagrant and WordPress”

    1. Thanks, Leo. Glad you liked it and I do hope it helps somebody. Thank you for building that tool!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Brett Shumaker

Subscribe now to keep reading and get access to the full archive.

Continue reading