by Tony Gamble
You’ve spent a lot of time and effort setting up your new WordPress website, and now it’s live for all to see. Great content has been drawing traffic and the word is spreading. You keep your site secure by staying on top of all available updates, until one day you update ’Plugin X’ and users find themselves visiting a blank white page. Of course, you’ve been following Tony’s Tech Tips, in particular this post about the dreaded White Screen of Death, but in the meantime your visitors move on to greener pastures. If only you could have tested this latest round of updates elsewhere. Well, you can.
The best way to test out updates and new features is to recreate your website as an offline install on your own computer. In this way, you can play around with new functionality and styles to your heart’s content without risking the stability of your public-facing site. But a website needs a web server. So how do you go about turning your own computer into its own server? It’s easier than you might think.
The most popular web development platform has long been provided by an application called WampServer. This free Windows package includes everything you need to get up and running: Apache server, MySQL database and PHP engine, all the stuff you need to run WordPress, Drupal or plain old static HTML website. When installed, it creates a directory on your hard drive (
c:\wamp\www by default) where you can place a folder containing your website. Once that is done, you’ll need to import a copy of your site’s database. You can obtain this from your host’s database CPanel, or you can do it the easy way and install the SQL Export plugin on your live site. This will allow you to easily export a zipped copy of your database from within the WordPress Tools menu. Unzip the downloaded file and use your favourite text editor to do a Search & Replace for all occurrences of the live website’s address. Replace them with
localhost/sitefolder, save and now you’re ready to import it into a database on WampServer through the PHPMyAdmin interface. Just make sure the database name and username match what you have set up in the wp-config.php file in the root directory of your
localhost website (remember, that’s in
c:\wamp\www\sitefolder by default).
All of these steps are applicable to the Mac OS X equivalent application called MAMP. The directory that this package sets up to house your website is called htdocs rather than www, and you can find it under
/Applications/MAMP/htdocs/. This is where you’ll place the folder of a copy of your live site. From there, the process is the same as for WampServer, except that instead of replacing your website address with just
localhost/sitefolder, you’ll need to use
localhost:8888/sitefolder instead (to login to the WordPress admin screen, use
localhost/sitefolder/wp-admin). Or, if you purchase the MAMP Pro version, you can use their super easy interface to set up a virtualhost address instead; something like
mywebsite.dev instead of
localhost:8888/sitefolder. This is great if you have more than one site to work with and I highly recommend it. You can do the same thing with WampServer, but it requires a lot more footwork and no simple interface to manage it. Not to worry, Windows users, MAMP Pro will soon be available for your platform as well.
Now you have a safe haven from which you can toy with your website, testing out updates and new features before deploying these changes to the live site. Your visitors will thank you.