Apostolos Dountsis

Web Development & Desktop Application Solutions
  • rss
  • Home
  • Projects
    • Easy Peasy Image Gallery
    • Social Bookmarks
      • Social Bookmarks Release Notes
      • Social Bookmarks Supported Sites
    • Move Comments
  • Downloads
  • Freelance Services
  • Photo Gallery
    • U2 – Vertigo Tour (Rome, Italy)
    • Brighton
    • Amsterdam
    • Athens 2004
    • Holiday Snapshots
  • Portfolio
  • About
  • Contact

Setup a Development Environment for Your WordPress Site

How many times you have stumbled upon a theme or a plug-in that you want to test on your site? WordPress does not offer a preview feature so the only option is to make it live which should not be the prefered (and only) option while testing or in general experimenting with new features.

In this article, we will investigate how we can setup a copy of our WordPress powered site on a local machine will serve as a development and test environment.

Prerequisites

The following tools are needed:

  • WordPress Backup Plugin (included by deafault as part of WordPress)
  • XAMPP (if you are using Windows) or MAMP (if you are using OS X)
  • phpMyAdmin (included in XAMPP and MAMP)

Step 1 – Backup your site

I am certain that everyone is backing their site every week so it is safe to assume that you do not need any instructions on how to do a full backup…. just kidding! Backing up any WordPress site is a two step process.

The first step involves backing up the database that WordPress uses and the second step involves backing up the WordPress core files, your themes and plugins from the remote server.

Database Backup

WordPress includes a plugin for automating the process of backing up the MySQL database. The plugin can be accessed from the admin section (Dashboard), under Manage > Backup. The plugin automatically selects the core tables but since third-party plugins may use extra tables, a list is displayed on the right-hand side where you can select additional tables. As a rule of thumb, any table with the wordpress prefix (default value ‘WP_’) should be selected.

Select whether you want to email the backup to yourself or download it directly to your local machine and press the Backup! button. When the operation is finished you have made a backup of the WordPress database.

WordPress Files Backup

In order to backup the files, you need to use an FTP application like WinSCP if you are running Windows or CyberDuck if you are running Mac OS X.

Start your FTP application and connect to your WordPress server. Navigate to the wp-contents directory of your remote server and download all the files and directories it contains to your local computer.

Step 2- Install local web server

You need to install a web server on your local computer. The easiest approach is to download and install an Apache web server containing MySQL, PHP. XAMPP is the best product to use if you are running Microsoft Windows. If you are running Mac OS X then MAMP is your friend. Both of them are really very easy to install and to use – just download, extract and start.

Note that both of them create a root account for MySQL with blank password or with the word “root”. It is highly recommended to change the password to something else and use that password when installing WordPress.

phpMyAdmin is also installed as part of XAMPP and MAMP. 99.99% of the times, it resides on the phpmyadmin directory (or an alias is in place for this location). Open it up, and create a database for the WordPress development site.

Step 3 – Install WordPress

Download a copy of WordPress from the WP site. Extract it into the httpdocs or www folder of your XAMPP installation. Navigate to that directory through your browser and complete the WordPress installation process.

Step 4 – Import your Settings

Our first step was to backup the WP database. We will now use the produced MySQL script to populate the backup WP system with our site settings.

Open the MySQL backup script with your favourite text editor, and search for the term ‘wp_options’. That’s the table that holds your settings. We need to remove the ’siteurl’ entry since it is now different on the local server (and the correct entry for ’siteurl’ was created during the WordPress installation for us). So, delete the line that reads something like:

INSERT INTO `wp_options` VALUES (1, 0, 'siteurl', 'Y', 1, 'http://www.dountsis.com', 20, 8, 'WordPress web address', 1, 'yes') ;

Save the changes and close the file. Navigate to phpMyAdmin and select the database where you have installed the development WP site. Execute the database backup script to import the dev system with your content and settings.

Finally, copy the local copy of the WordPress Files backup (themes and plugins) that was created during the 1st step to the equivalent location of the development site.

The development/test environment should now be an identical copy of the live site where you can test new themes and/or plugins or develop your own.

1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 4.33 out of 5)
Loading ... Loading ...

Bookmark This Page

Add to Buzz Add to Del.icio.us Add to DotNetKicks Add to Facebook Add to Google Bookmarks Add to Mister Wong Add to Tip'd Add to Twitter Add to Yahoo My Web
Hide Sites
Categories
WordPress
Tags
PHP, WordPress
Comments rss
Comments rss
Trackback
Trackback

« Automatic Restarting in XP Firefox 3 Beta 4 »

11 Responses to “Setup a Development Environment for Your WordPress Site”

  1. Tranpalitu » Blog Archive » Configurar un entorno de desarrollo para tu sitio WordPress says:
    December 17, 2007 at 22:29

    [...] post es una traducción del original obra de [...]

  2. Nick says:
    December 27, 2007 at 13:57

    Cheers for that!!

  3. Sven says:
    March 17, 2008 at 15:08

    Excellent post, i use same way in my theme production environment

  4. Rowan says:
    July 25, 2008 at 23:42

    Hi. In fact you don’t need to do the mucking about with the wp_options table if you make some simple changes to your wp-config.php. I talk about this in my own blog. [Beware: the theme looks horrible in MSIE at the moment. :-/ ]

  5. Gordon Morehouse says:
    September 18, 2008 at 0:23

    If you replicate your blog’s database to a test server as well, you can run this after the sync:

    UPDATE wp_options SET option_value=’[URL TO TEST BLOG HERE]‘ WHERE option_name IN (’siteurl’, ‘home’)

  6. Sumedh says:
    December 17, 2008 at 15:32

    Hi…

    I want to do exactly the opposite of what you’ve done…

    I have dev running fine…want to put it on production now…

    So, how do I do the installation procedure?

  7. links of london says:
    July 28, 2009 at 3:54

    Good article!

  8. Jim says:
    July 29, 2009 at 21:20

    Just one quesion on this great article. The export make a XML file. I took it into ‘edit3′ my editor and did a find on ‘wp_options’ and it returned no text. I did a search on URL and only 2 lines refer to the site address alone

    wp:base_site_url
    wp:base_blog_url

    could these be the ones we need.

    Thanks

    JIM

  9. m says:
    August 5, 2009 at 15:32

    Hi,

    I’m using Wordpress 2.7 and trying to create mirror of my wordpress site on my local MAC computer. I have followed your instructions but can’t seem to get it to work properly and would appreciate some help.
    Step 1 – Backup your site

    Database Backup
    Quote: The plugin can be accessed from the admin section (Dashboard), under Manage > Backup.
    I can’t find this in Wordpress 2.7 has it been replaced by something else?
    In the mean time, I’ve tried to proceed using the plugin : wp-db manager 2.31. Does this do the same thing? or do you have another recommendation ?

    Wordpress Files Backup
    I’m using FTP application : FileZilla 3.2.6.1. The download was to big (Gallery Folder is > 100 gig) so I compressed the files first before downloading. Is there an easier way?

    Step 2- Install local web server
    Done

    Step 3 – Install WordPress
    Done

    Step 4 – Import your Settings
    b. i can’t find the exact line in step 4 that i’m supposed to delete. Has this changed in WordPress 2.7 or is i the plug-in that has changed the Database ?

    I need help!!!!

    Thanks

  10. Alex says:
    November 15, 2009 at 5:00

    Assuming I’m satisfied with whatever changes it is I’m making, do I mirror my changes to production the same way? i.e. backup files and DB on my local computer, and then import to the live wordpress?
    If I’m making minor changes here and there, sometimes on the server, sometimes in test, then mirroring by backup/restore gets to be quite time-consuming. Is there a better way?

  11. kumaran says:
    January 27, 2010 at 10:58

    thanks a lot u admin. i was smashing my computer monitor for two hours to find this article content.

Leave a Reply

Click here to cancel reply.

About Dountsis.com

Dountsis.com is the site of the web developer, technology enthusiast, and gadgets addict, Apostolos Dountsis. The articles on this site focus on web development, software and freelance.

Topics

  • EPIG (2)
  • Firefox (6)
  • Funny (1)
  • Programming (3)
  • Site Updates (7)
  • Tutorials (4)
    • .NET (1)
    • PHP (3)
  • Windows (5)
  • WordPress (25)

PayPal Button

If you feel that the open-source projects that I develop and deliver through the site are worth a penny then you could press the button below to send it to me.

Keywords

.NET adblock Bad Sectors C# chkdsk Del.icio.us Eclipse Extension Firefox Hard Disk Microsoft Move Comments PEAR PHP Social Bookmarks Spam User Control Windows Windows XP WinForm WordPress

What I'm Doing...

  • Nite nite 1 week ago
  • RT @JulieMaggot: Τζουλια ΕΕΕΛΑΑΑΑΑ!, Θα κανουμε Σαμπανιαααααααααααα!! #julia_porn 1 week ago
  • My back! Ouch ouch 3 weeks ago
  • More updates...

Recent Articles

  • Social Bookmarks 4.1.2 Point Release
  • How to use User Controls to create MDI WinForm Applications
  • Social Bookmarks Sites Cleanup
  • Social Bookmarks 4.1.1
  • WordPress Plugins Activation Order
  • WordPress Plugin Development

Spam Blocked

65,105 spam comments
blocked by
Akismet
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox