BY indefiniteloop

I’ve been using Vagrant for a long time now. It’s been good to me. Takes away the hassles of compatibility issues, and provides reliable CI/CD with Jenkins. It also allows you use any platform, or suite of tools you require for your development project needs, or workflows.

I thought I’d share a Vagrant setup I use, and have used to develop some WordPress projects in the past. Most of what you see in the gists can be tempered with to allow you to install, or setup whatever else you may require for your development workflow. It’s the very basics of Vagrant. I am not gonna go too deep here. But if you did want to know more, just leave a comment.

The Vagrantfile

The Vagrantfile describes the machine required for your development / designing project. It also tells Vagrant how to configure these machines, and what to use for provisioning them. You have many options that you can choose for provisioning; including Puppet, and Chef. I use basic shell scripts. Keeps things simple on my end.

Every project will have it’s own Vagrantfile. If you’re using git, do not add this file to your .gitignore.

I use the file to tell Vagrant what I need once the machine is setup. This is only run once, unless you specify otherwise (see For the WordPress based projects, I install the AMP stack, and then fetch WordPress.

There’s a lot going on in this file. I don’t like using /var/www/html for my projects. Instead every Vagrant machine shares a folder with it’s host. The default folder is /vagrant. To make things easier, I make this folder my DocumentRoot. Easier to move files, and what not.

There are some locking, and permissions issues that I’ve faced when I’ve changed the DocumentRoot. The file will run every single time this Vagrant machine is run, after halts. The web server, and mysql restarts in this file take care that the permissions, and locking issues don’t happen.

The End Result

Once this VM is up, and running, simply point your browser window to http://localhost:4567. Follow WordPress’ famous five minutes install, and you’re all ready to go.

Hope this helps someone out there.

Using Vagrant to set up a WordPress dev sandbox/environment.

On GitHub

You can use all the three files to start your own dev environment. Simply download from the github repo, using the button below. Alternatively, you can fork it (always wanted to say that!).

Download all three files.

Fork on GitHub.

If you have your own Vagrant “recipes” share a link below, and let me know!

About The Author:

Home Full Bio