VagrantPress is an open-source development environment based on Vagrant which allows you to run a local version of a WordPress installation. It’s a super-easy way to create a virtual web sever with WordPress so developers can build plugins and themes without the need of a live development server. It also cuts out the latency between your local environment and a web server as well as the processing restrictions your server may have.

VagrantPress is freely available from GitHub, and takes only a few simple steps to get up and running.

In order to download and instantiate a VagrantPress server, we need to have Git installed via our command-line interface. Steps may vary slightly for different operating systems, but the general procedure is the same. This tutorial has been written for macOS (formally known as OS X).

How to setup a virtual server for WordPress using Vagrant on macOS

Step 1: First, let’s install git. The easiest way is to install it via Xcode Command Line tools. Do this by launching Terminal and typing “git” followed by the enter key. You will be prompted to install the Xcode Command Line tools so follow the instructions on your screen to do so.

Step 2: Next, you want to download and install Vagrant. Download the latest installer package from the Vagrant website here. Once the download has completed, open the installer and complete the installation using the default settings.

Step 3: Without getting too technical, Vagrant requires VirtualBox. Essentially, any virtual servers that are created will exist inside a VirtualBox node. VirtualBox is a free virtualisation software that allows you run environments within a window, similar to Parallels Desktop. Download the latest version of VirtualBox for your operating system from here. Once the download has completed, open the installer and complete the installation using the default settings.

Step 4: I would also recommend you install another command-line tool called vagrant-hostsupdater. This plugin automatically makes changes to your hosts file so you can reach the virtual WordPress installation through a common domain than an IP address.

From Terminal, enter the following and follow the on-screen steps to install the hostsupdater plugin:

vagrant plugin install vagrant-hostsupdater

Step 5: Now we want to copy all the files from the VagrantPress GitHub page to a folder somewhere on our hard drive. This folder will contain the files for our virtual environment which includes our WordPress files.

Since we have installed Git, there is a very easy way of doing this.

Open terminal and navigate to where you would like to save your files. For example, I prefer keeping it in my Downloads folder so in Terminal I would type the following:

cd /Downloads/

We can now clone the GitHub repo to a folder within the Downloads folder using just the command line via Terminal. I will put it in to a folder called Technouz – you can choose whatever you like. Now, in Terminal, enter the following:

git clone http://github.com/vagrantpress/vagrantpress.git Technouz

(Replace ‘Technouz’ with the name of a folder of your choice).

Step 6: The GitHub repo will now be cloned to the ‘Technouz’ repo. Let’s enter that repo by entering the following in Terminal, followed by the Enter key:

cd Technouz

Step 7: We now want to use the files we have cloned to create a virtual environment, and automatically install WordPress. To do this, enter the following from the Terminal window:

vagrant up

Step 8: The command line will now initialise the virtual environment. Once completed, it may ask you for your administrator password. Open Finder and you will see there is now a wordpress folder in the directory. Within this folder there are the familiar wp-content, wp-admin and wp-include folders.

You can get access to the WordPress installation by visiting the following URL from your internet browser:

http://vagrantpress.dev/wp-admin

The default login details for the WordPress administrator account are admin and vagrant.

For all available Vagrant commands (including deleting the virtual machine, restarting and starting afresh) see the Getting Started docs on the Vagrant website.