Creating a Dev box from an existing production machine?

  1. Yes, reasonable. Setting up development clones of WordPress is very easy.

    • Copy your files (rsync/scp are fine) to your dev server
    • Setup a new database and database user (and setup permissions) on your dev server
    • Update your wp-config.php file with your new database info: DB_NAME, DB_USER, DB_PASSWORD, DB_HOST (if other than localhost)
    • Update: If this is Multisite, you will also need to update DOMAIN_CURRENT_SITE to your dev server domain.
  2. I use the following tool: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ to run a search and replace on the database. (Using something like this is key, because there is typically serialized data in your WordPress tables. Usually in wp_options or wp_postmeta.

Just dump it in your base WP dir and pull it up in your browser. It will automatically populate your database details (if it doesn’t, you can manually enter them), and enter your search/replace parameters.

You have the opportunity to do a dry run to see what (if any) rows will be updated.

The only other things I’d say do/check for is place the following in your wp-config.php file (replacing http://example.com with your dev domain, remove or update domain for production):

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

and make sure there are no hard coded paths in any of the theme files that your scripts might rely on.

Between defining those and the DB search/replace you should be golden.

Lastly, here is WP documentation for migrating to another server. Might be a handy reference for you: http://codex.wordpress.org/Moving_WordPress

Update

You’ll want to make sure that your .htaccess file (located in the base WP directory) is carried over as well.

  • For a normal WordPress install, you could simply refresh the permalinks (Dashboard > Settings > Permalinks > Save/Update) which will automatically rebuild the .htaccess file for you (if WP can write to the directory). Otherwise you’ll have to manually create it, and use the rules displayed on the Permalinks page.

  • For a Multisite install, there are specific rewrite rules depending on your setup that you can pull from Network Settings > Network Setup.

Leave a Comment