1704 days since this post was last revised. Specific details are likely out of date.

This post explains how to make a local development version of a standalone WordPress website (e.g. self installed not hosted at wordpress.com). Crucially, it will automatically amend your url’s from mysite.com/file to localhost:8888/file without having to alter the DataBase.

I’ve done this many times in the past. However, perhaps it’s my imagination but it seems I always have to do things differently to get things working. Hopefully, if you’re in the same boat this will help. Here was my situation:

I had my WordPress site here (benfrain.com) and wanted a local MAMP based version for testing changes before pushing it live. Whenever I have done this previously I have used something like Velvet Blues Update URL’s plugin so that URL’s went to the local links (e.g. localhost:8888/file), rather than the remote ones (e.g. benfrain.com/file). However, I noticed this entry on the WordPress Codex: http://codex.wordpress.org/Running_a_Development_Copy_of_WordPress. It promised to let me keep the DataBase in tact and still get the updated URL’s – perfect, no? Sadly, as ever things didn’t go exactly right. Here’s what I did to get things working.

I was using WordPress v3.3.1:

  • Download the existing WordPress site files from the LIVE site (either FTP or SSH) to a local folder on OSX (e.g. /Users/benfrain/Sites/WordpressSite)
  • Export the LIVE database from phpMyAdmin or with SSH and save it into the same local folder (if using phpMyAdmin and you have a large DB, you can gzip the export file as phpMyAdmin can import gzip files in MAMP (up to 32MB in size))
  • Open MAMP, open phpMyAdmin and make a new blank database with the SAME DB NAME as your LIVE DB.
  • Import the LIVE DB into the MAMP DB with the same name (using phpMyAdmin).
  • You are now done with the LIVE site by the way, you can close your FTP/SSH session for it.
  • Open the LOCAL copy of wp-config.php (in the root of WordPress) and edit your settings to match the DB name but change the DB_USER and DB_PASSWORD settings to this:
  • /** MySQL database username */
    define('DB_USER', 'root');
    /** MySQL database password */
    define('DB_PASSWORD', 'root');

    Then add this to the end of the same file. Change ‘YOURSITE’ to match the URL of your LIVE site:

    /** Sets up WordPress vars and included files. */
    define('WP_CACHE', true);
    $currenthost = $_SERVER['HTTP_HOST'];
    $mypos = strpos($currenthost, 'localhost');
    if ($mypos === false) {
    } else {

    It should go just above this line:

    require_once(ABSPATH . 'wp-settings.php');
  • That should be all there is to it.

Now restart your browser and view http://localhost:8888 and as long as your other MAMP settings are correct (remember to set the document root in the Apache tab to match where the downloaded files are (/Users/benfrain/Sites/WordpressSite in this example) you should see a local version of your site with URL’s linking to localhost:8888 file instead of the live URL’s.