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: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience 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 bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.