Print

Copy a Wordpress Site for Development

Applies to:
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
    copyraw
    // ** 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');
    1.  // ** MySQL settings - You can get this info from your web host ** // 
    2.  /** The name of the database for WordPress */ 
    3.  define('DB_NAME', 'my_database_name')
    4.   
    5.  /** MySQL database username */ 
    6.  define('DB_USER', 'my_database_user')
    7.   
    8.  /** MySQL database password */ 
    9.  define('DB_PASSWORD', 'my_database_password')
    10.   
    11.  /** MySQL hostname */ 
    12.  define('DB_HOST', 'localhost')
    13.   
    14.  /** 
    15.   * Authentication Unique Keys and Salts. 
    16.   */ 
    17.  define('AUTH_KEY',         'my_auth_key')
    18.  define('SECURE_AUTH_KEY',  'my_secure_auth_key')
    19.  define('LOGGED_IN_KEY',    'my_logged_in_key')
    20.  define('NONCE_KEY',        'my_nonce_key')
    21.  define('AUTH_SALT',        'my_auth_salt')
    22.  define('SECURE_AUTH_SALT', 'my_secure_auth_salt')
    23.  define('LOGGED_IN_SALT',   'my_logged_in_salt')
    24.  define('NONCE_SALT',       'my_nonce_salt')
  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');

Category: Wordpress :: Article: 602