How To Build a Speedy WordPress Sandbox VM

By Raena Jackson Armitage
We teamed up with SiteGround
To bring you the latest from the web and tried-and-true hosting, recommended for designers and developers. SitePoint Readers Get Up To 65% OFF Now

If you’re planning to break into the world of WordPress development, it makes sense to set up a dedicated development environment — and one of the best ways to do it is with a virtual machine. I prefer VMs to my Mac’s built-in server or servers like MAMP because you can run them only when you need them, pack them away when you’re done, set up as many different ones as you need, and share them with friends and co-workers with ease. And if you’re new to web server administration, setting up and maintaining a Linux VM is the perfect beginner project to practice your skills.

In this article, we’ll take a look at setting up a Linux virtual server with all the bits and pieces required to support a WordPress installation. If the words “Linux”, “administer”, and “server” give you the heebie-jeebies, you’re in luck — we’ll also show you how to use a pre-packaged WordPress server that takes just minutes to install and requires no knowledge of the command line. What’s more, since we’ll be making use of free and open source software, all it costs is a bit of your time and hard drive space!

Download and Install VirtualBox

Your first step is to acquire a virtualisation system for your desktop machine. We’ll be concentrating on VirtualBox, a free and open source virtualisation system for Windows, Mac, and Linux — you can grab it for free from the VirtualBox website.

Those of you who have shelled out for another application, like VMWare Fusion or Parallels, never fear — you can still set up these VMs in the system you already have, but you’ll need to consult your product’s documentation for how to do this.

Setting Up a Ubuntu Virtual Machine

If you’re confident with the command line — or you’d like to become confident — installing and configuring a VM from scratch might be the method for you. In late ’09, Louis showed us how easy it is to build your own dev server with VirtualBox. The steps to do so here in 2011 are largely the same, so there’s no need for us to repeat every step in this article — go ahead and check out that article for the full play-by-play. Before you do so, however, keep these three things in mind:

  1. In the article, Louis shows us how to set up port forwarding with an XML configuration file. In the latest version of VirtualBox, you can now also set up port forwarding in the VM’s Network Adapter settings panel. You can see these settings in figures 1 and 2, below.

    The Network panel with the Advanced twistie open, showing the port forwarding button

    Port forwarding setup in VirtualBox

  2. During the installation process, the Ubuntu 10.10 Server installer will ask you to choose the type of system you’d like to run. We’re after a LAMP server and we’d like to be able to log in using OpenSSH, so be sure to select that when asked. You can see this panel in figure 3, below:

    Choose the right packages for this server.

    Doing so ensures that Apache, MySQL, PHP, and the OpenSSH packages are downloaded and installed from the outset.

  3. This process takes a while, and you’ll need to set a few passwords and answer quite a few prompts — go brew up some tea or coffee, and pay close attention to every question, especially the ones that ask you for a password.

If you followed Louis’ instructions to the letter, and if all went well, you should now have a working Linux web server. Test this out by opening a web browser and heading over to http://localhost:8888. If you see a page that exclaims “It works!”, you’re on the right track.

In your VM window, you should also be greeted by a login prompt. Log in now, using the admin username and password you chose when you installed Ubuntu.

Grab WordPress

While it’s possible to install WordPress using Ubuntu’s package manager, it’s kind of idiosyncratic and fiddly. WordPress’ famous five-minute install is called that for a reason, and it works perfectly, so let’s install it this way, instead. First, head on over to the web directory, which should be /var/www:

cd /var/www

To grab the latest WordPress version, save yourself some tedious FTP-ing and have your VM download it direct with wget:


Now, unpack the zip:

tar -zvxf latest.tar.gz

All the WordPress files will be unpacked into a subdirectory of your website called wordpress. I’d prefer my blog to live at the root directory of my website, so I’ll be moving all these up one level:

mv wordpress/* /var/www

The default index.html file (that’s the one that says “It works!”) and empty wordpress directory can be removed:

rm -r index.html wordpress

Create A Database User and Password

During the Ubuntu installation process, the wizard asked you to specify a “root” password for MySQL. You’ll need that now, as we’re about to create a database for WordPress to use. The process for doing so is explained over on the WordPress codex, and goes a little something like this:

raena@wordpress:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.

Now, you’ll create the new database:

mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)

Next, set up a database user:

mysql> GRANT ALL PRIVILEGES ON wordpress.*
    -> TO "wp_user"@"localhost"
    -> IDENTIFIED BY "password";

Clean up after yourself, and you’re done:

mysql> EXIT

Easy! You can now start installing WordPress using the web-based installer — head on over to http://localhost:8888 again and follow the instructions from the WordPress Codex.

Setting Up A Pre-Packaged WordPress Appliance

If you’re less confident with the command line, or if you’d prefer a simpler and faster installation process, a pre-packaged VM appliance might be the solution for you. A VM appliance is a virtual machine file that’s already been installed and configured, with little or no need for adjustments on your part. WordPress’ Codex suggests two appliances: BitNami’s WordPress VM, and TurnKey Linux’s WordPress Appliance. The TurnKey Linux VM is the most user-friendly, particularly for less confident Linux users, and it’s the one we’ll use for this example.

First of all, you’ll need to grab the appliance. TurnKey provides appliances in a number of different formats, one of which is the Open Virtualisation Format, or OVF. This is a common format for appliances, and bundles up all the software a VM needs in one easy-to-digest package. Look for the OVF link in the download bar, near the top of the TurnKey WordPress page.

Once you have that file, simply open it in VirtualBox — you’ll be asked to confirm the settings inside it. There should be little need to play with anything you find here, except perhaps the name of the virtual machine (vm is the default — a little generic, right?). VirtualBox will import the file and convert it into a virtual machine; when it’s complete, you’ll see it appear in the left of your VirtualBox window.

Next, start the machine and keep an eye on the screen. You’ll set up your machine through a wizard, which will ask you to set up usernames and passwords for the machine’s root account, for MySQL, and for WordPress’ administration account. You can see the wizard in action in figure 5, below:

TurnKey Linux's wizard asking for a password

Be sure to make a note of these passwords. You’ll also be asked to set up the TurnKey cloud backup service, daily security checks, and whether you’d like to update your machine right away. It’s fine to skip the TurnKey backup setup for the time being (you can always enable it later), but it’s definitely important to set up your security updates now. It’ll take a few minutes, so grab a cup of tea or coffee while your machine does its thing. When it’s finished, you’ll see the TurnKey configuration console, which tells you everything you need to know to reach your website and to administer it — check it out in the figure below. Your WordPress blog is installed and ready for action at the address specified under “Web”, and you can administer your new server’s other goodies using the command line or the easy Webmin interface. Double-check now that you can log in to your system and that the WordPress site is definitely installed.

The TurnKey Appliance Configuration window

Since your appliance may have originally been created days or even weeks ago, you may find that you need to update some of your plugins, or even WordPress itself. Once you’ve done that, though, you’re ready to rumble!


Now that you’re up and running, you’re ready to fill your blog with interesting test content and start hacking on your plugins or themes. As with most things WordPress, the Codex is your best friend when it comes to tips, tricks, and troubleshooting advice — start with the Server and Database heading on the Advanced Topics page for some great information on what’s going on under the hood there. Don’t forget about the WordPress, Hosting and Apache sections of our forums, too!

We teamed up with SiteGround
To bring you the latest from the web and tried-and-true hosting, recommended for designers and developers. SitePoint Readers Get Up To 65% OFF Now
  • Michael

    Why not just install a wamp, mamp-bundle – and thats it? You can still shut it off when you want. It just another ‘famous five minutes install’…

    • Wolf_22

      Because that’s too easy, Michael. ;.)

      Using Vbox, you’re likely to have a better tool set (I suppose it’s debatable, especially considering that we’re talking about WordPress here and not some enterprise app).

      It’s true, using WAMP is as easy as it comes, but what if you have to test for things like SSH or permission handling? Custom PHP.INI tweaks or HTTPD configs? I suppose these kinds of things could be synthesized using WAMP somehow, but not without a lot of meta development overhead. In all reality, the best way to do a sandbox isn’t with Vbox nor WAMP, but instead, with an actual full-fledged server that has a 1-for-1 environment of your prod box. Of course, not everyone can do this, ap pro po, Vbox and WAMP.

      Either way, I’ve had Vbox slated on my to-do list for awhile now. Ironic how I now come across a great tutorial for it! Total win for moi’!

      • Iggy

        “what if you have to test for things like SSH or permission handling? ”

        Then you need to do your dev on a Mac :)

      • Hi Michael,

        I wrote a response to Armen below that you might find interesting but also, Wolf speaks to a very good point: it’s a method that is much better at replicating an enterprise environment. And even if WP is not itself an “enterprise” app, it’s used in enterprise.

        Thanks fr writing :)

  • Armen

    sorry, but am i missing something? supposed i have a Mac which comes preinstalled with Apache and PHP. and all i need is to install MySQL (which takes couple of minutes). So why do i need to run virtual machine, which may be slower and sometimes buggy?

    • Hi Armen,

      Like I said, a VM is my preference because it means I don’t have to mess about with my desktop. I can also send the VM to a friend or colleague without too much hassle or move it to a different machine. There are also times when I can take an entire VM and shove it right to production (have a read of the Turnkey Linux folks’ cloud deployment stuff, it’s awesome), and even if I can’t, a real Linux distribution is much closer to a client’s production environment than my Mac ever will be.

      Don’t get me wrong, I use the built in Mac web server all the time for simpler stuff (and WP is definitely simple enough), but I like the convenience.

      Thanks for writing.

  • DJ

    I have both a WAMP server and virtual machines using VMware. It’s free, installs in minutes and all of the Linux distros install easily. Both of these have served all of my needs for more complex things than WordPress.

  • Jeff

    Great tutorial to get people up and going ASAP. Good job to you for getting it done. Also, great mention on the references at the end for peeps to go if they have to scratch their head more than twice.

  • Aaron

    I agree with Michael “Why not just install a wamp?” Wamp is much, much better. Even better than xampp. I use wamp and I think wamp rules!!!

    • Louis Simoneau

      I think “anyonymous”‘s comment below is the deciding argument for me. There’ll always be server configurations or other weirdnesses that I want to play around with for one of my sites or projects, and I don’t want that to ripple through every other site.

      Maybe for really quick messing around, running a server on your desktop is okay, but for any kind of more in-depth dev work, a VM is essential.

      • John King

        I find I can do so much more than ‘messing about’ with WAMP. And by changing a few config files I can work on and migrate WordPress projects with no messing about at all.

        For me I’d say if you have the time on your hands and fancy dabbling with VMs or if you have a project that ‘really’ needs it then feel free to go down the VM route. 99% of WordPress projects just don’t need it.

        Great article for beginners though. Thanks.

  • Anonymous

    Great tips.

    I’ve been doing this same exact thing for a few months now. It is SO much better than a local server or any other method that I’ve used in the past.

    My favorite thing is I will create a new server for each project I’m working on. This lets me freely mess with any and all server configurations without having to worry about accidentally messing it up for another one of my projects.

    If you set up FTP on the server, you can then just use Dreamweaver or something and communicate via insta-FTP to your server, so it’s just like normal development. (You can also set up shared folders, but that’s a bit of a main, especially if you’re on a domain).

  • Francois

    Awesome article Thanks!!

  • Kris

    Why not go directly install WP to a live domain if you’ve got a fast Internet connection? Then have a backup every time you will make a change.

  • turnkey wordpress is great for when you need a fast installation.

    I use it for black box security testing of wordpress plugins.