There 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.
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:
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.
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:
And finally, if you need to SSH into the virtual machine:
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