Contact
Site: US UK AU |
Nexcess Blog

Fast And Easy WordPress Development Environments With VagrantPress

February 2, 2016 2 Comments RSS Feed

WordPress Development EnvironmentThere are many reasons a WordPress user might want to create a WordPress installation on their local machine.

  • Testing plugins and themes before deploying them on a live site
  • Creating a dev site for theme development
  • Running WordPress Betas to try new features

Installing WordPress on your desktop or laptop can be a complicated procedure, and most people don’t want to run the entire LAMP stack on their everyday machine, so there are numerous solutions that allow users to create a “sandboxed” WordPress that has everything it needs to run without polluting the user’s PC with software that it wouldn’t otherwise need.

I used MAMP for years, but for the last few months I’ve been creating local WordPress installations with VagrantPress — it’s quick, easy, and you can create as many WordPress installations as you need in seconds.

What Is Vagrant?

In a nutshell, Vagrant is a tool for building lightweight, portable virtual environments. Vagrant uses a Vagrantfile, which can be thought of as a recipe for building a virtual machine with all the applications developers need to carry out a specific task. Because Vagrant creates virtual machines, the development environment is separate from the host machine.

VagrantPress uses Vagrant to build a complete WordPress development environment with an installation of WordPress running on it.

Installing And Configuring VagrantPress

The installation instructions will vary depending on the operating system of your testing machine, so I’m going to assume you know how to install software and access your operating system’s command line.

First, you’ll need to install Vagrant and VirtualBox. VirtualBox provides the hypervisor and virtual machine management tools that Vagrant will use to build our local WordPress installation.

Next, you will need to download VagrantPress itself. The easiest way to get it is to clone the VagrantPress GitHub repository, but you can download a zipped version if you prefer.

Once you have VagrantPress unzipped and placed in a folder, you will need to install a Vagrant helper plugin that takes care of configuring the host environment so that it can easily connect to the WordPress instance running on the virtual machine. Run the command:

vagrant plugin install vagrant-hostsupdater

Once that’s done, make sure you’re in the directory that contains VagrantPress’ Vagrantfile and run:

vagrant up

The first time you run this command, it will take a few minutes to download the disk image of the virtual machine, so sit back and wait until the text stops scrolling past. All being well, you’ll see no errors.

VagrantPress

To access your new WordPress development installation, visit “http://vagrantpress.dev” in your browser — you should see the familiar site of a brand new WordPress installation. You can access the administration dashboard at “http://vagrantpress.dev/wp-admin”. The default login credentials are “admin” and “vagrant”.

You can “turn-off” the virtual machine running VagrantPress with either the “vagrant suspend”, or the “vagrant halt” commands , which will suspend it to disk or shut it down, respectively.

If you want to destroy the virtual machine and get a fresh installation, use:

vagrant destroy

And finally, if you need to SSH into the virtual machine:

vagrant ssh

And that’s about it, you now have a fully functioning disposable WordPress environment that you can test things on without having to worry about breaking your live site.

Posted in: WordPress
  • Joe d. St. Clair

    I have a similar Vagrant based development environment that I put together for Magento 1.x CE. The current version is set up for Magento 1.9.2 Community Edition. I plan to upgrade and test with CE 1.9.3 next week.
    https://github.com/jay-saint/simple-magento-vagrant
    It currently installs Magento along with composer and n98 magerun and optionally installs sample data.

  • Dan

    Nice Article ! thanks for share a useful information.