Applies to:
  • Wordpress CMS v4.1.1

What?
A note to myself on how to create a development/test version of a production/live Wordpress CMS site.

Why?
I have a website sitting at a domain (eg. www.myexample.com), and I want to create an exact copy at a subdomain entitled "dev1" (eg. dev1.myexample.com).

How?
A quick copy from copy 1 (LIVE) to copy 2 (DEV):
  1. Backup all files in LIVE environment
  2. Delete any files in DEV except for "wp-config.php"
  3. Copy all files except for "wp-config.php" from LIVE to DEV
  4. Copy the salt and secret keys from LIVE\wp-config.php to DEV\wp-config.php
  5. Backup the database in LIVE environment
  6. Clear the database in DEV
  7. Copy database from LIVE to DEV
  8. Change database values: Navigate to wp_options table and change the two values
    where `option_name`='siteurl' change `option_value` // from www.myexample.com to dev1.myexample.com
    where `option_name`='home' change `option_value`    // from www.myexample.com to dev1.myexample.com
  9. Search and replace any other occurrences in the `wp_options` database table (note: include `wp_postmeta` and `wp_posts` if you want images and attachments)
  10. Done

Sample Configuration PHP
Note that the following are sample values and just for myself to quickly modify a Wordpress configuration file.
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'my_database_name');

/** MySQL database username */
define('DB_USER', 'my_database_user');

/** MySQL database password */
define('DB_PASSWORD', 'my_database_password');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/**
 * Authentication Unique Keys and Salts.
 */
define('AUTH_KEY',         'my_auth_key');
define('SECURE_AUTH_KEY',  'my_secure_auth_key');
define('LOGGED_IN_KEY',    'my_logged_in_key');
define('NONCE_KEY',        'my_nonce_key');
define('AUTH_SALT',        'my_auth_salt');
define('SECURE_AUTH_SALT', 'my_secure_auth_salt');
define('LOGGED_IN_SALT',   'my_logged_in_salt');
define('NONCE_SALT',       'my_nonce_salt');