Copy a Wordpress Site for Development

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
    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

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.