Wordpress Development with a Virtual Linux Server
Posted by BYurick | Posted in General | Posted on 09-02-2009
Comments 1
Tags: development, Fusion, guide, how to, MySQL, virtualization, wordpress
Virtualization is one of the newest and fastest growing segments of IT. It allows you to run a whole new operating system or server on your machine that is completely seperate from your workstation. It lives in its own little virtual world. If you plan on doing a decent amount of editing to your Wordpress blog, having a dedicated development environment is a good idea and virtualization can help.
Note: do not under any circumstances use this tutorial to set up a live public facing server. These instructions do not set up the proper security and are for local development only!
With this dev area, you’re free to make changes or create a new blog, theme or just mess around with the inner workings of Wordpress without having to worry about setting up a new site on your host account or screwing up your existing site. There are many tutorials out there that show you how to install and run Wordpress locally on your Windows, Mac or Linux computer. My personal preference is to run a virtual linux server on my iMac. Why? Well there are a few reasons:
1) I don’t have to mess with my operating system and make changes that can possibly affect other software on my machine.
2) It’s closer to the real hosting environment that your blog lives on.
3) If I make a change to the virtual server to test something and screw it up, I can just delete my old virtual machine and run a clean backup that’s good as new in seconds.
There are quite a few programs out there that can run virtual machines on your workstation. My preference is VMware Fusion (not free), but there are other options you can use with any operating system that range from free to not free (here’s a couple).
VMware server edition – Windows – free
Virtualbox – Windows, Linux, Mac – free
Parallels – Windows, Linux, Mac – not free
The following directions are based off VMware Fusion and it already having been installed, but the basic overall concept will be pretty much the same no matter what software you end up using. After you’ve installed either your free or non-free virtualization software we need to download an ISO image of Ubuntu server for our virtual linux server. I got the latest version (it will be almost 600mb so be prepared).
Now that we have our ISO, open up your virtualization software. We want to add a new machine, name it something familiar and follow the prompts. I set my network settings to “bridged” so that the server will have it’s own IP on my network. Just picking the default options will probably be ok for most applications, it’s kinda hard to screw this part up anyway. I only set up a small amount of diskspace on my Firewire drive (about 2GB) for the server to run on. You can make this whatever you want, but I suggest keeping it as small as possible. It’s only going to be a development server anyway for testing.
Open the new server you just created, click on the CD icon and point to the Ubuntu server ISO you downloaded earlier. Then start your virtual machine and follow the install instructions. Remember the user name and password that you create during the installation. We’ll need this to get configure MySQL through the command line and to also get sftp access so we can upload the Wordpress files.
When you get to the following screen, select the options seen below:
Once the install is done, you may need to reboot it. When it comes back up you should see something like this:
Log into the server, then type the following command to set your MySQL root access password (change NEWPASSWORD to something easy to remember)
mysqladmin -u root password NEWPASSWORD
Logging into your MySQL should look similar to below. You can use this as a guide:
Type exit to get out of there and back to the Ubuntu login screen. Type ifconfig and make note of the ip address (next to inet addr:). Type that address into a browser and see if Apache is running:
Now we need to set the root www folder permissions. Here we’re going to do it through the sftp program. I use Transmit since I’m on a Mac. FileZilla works too, or on Windows I use WinSCP. Any one of those will work just fine, just make sure you’re using port 22 and logging in with the user/pass you use to get into Ubuntu. Then we’ll go the /var/www and set our file permissions:
Now that our basic Ubuntu dev server is set up, shut down the virtual Ubuntu machine. Browse on your computer to where you saved the virtual file that is your Ubuntu server. We’re going to make a clean backup of the virtual file itself so we always have a new machine just in case we royally hose this one:
With that done, start up the original virtual Ubuntu server and log in. Next, log into MySQL. We’re going to create a database for our first dev Wordpress blog. Make the database, user and password whatever you want but I suggest making is something simple:
mysql> CREATE DATABASE databasename;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON databasename.* TO “wordpressusername”@”hostname”
-> IDENTIFIED BY “password”;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> EXIT
Bye
Now, use your sftp program to log into the file system. Browse to your /var/www folder. I suggest adding a new folder in here and making that the root of your blog. That way you can add as many as you want (blog1, blog2, blog3, etc) and we don’t have to mess with the Apache httpd.conf file or make host headers:
Upload your Wordpress site files to the one of the blog folders from above and remember to set the wp-config file with the MySQL database, user, password for localhost and run the usual install process. Now you can go wild developing with Wordpress and playing with your virtual server. And just in case you really mess up the server and can’t fix it, simply shut the virtual machine down first. Delete the old Ubuntu file we created in the very beginning. Then make a new copy of the clean one and use that new clean copy to start your virtual linux machine. You will likely see a message similar to this:
Just tell it you copied it. Be sure to always keep an untouched clean copy as a backup.





Nice tutorial thanks. You could always install XAMPP for Linux server once trhe server is up and running – makes everything a lot less scary in my view.