I always do this, so I’m posting it here for my personal reference.  Feel free to follow the steps I made here.

  1. Log into your cpanel. (For instructions to log in to cpanel, please click here or follow your webhost’s instructions)
  2. Create a subdomain. that is used for accessing the testing site. For example dev.yourwebsite.com.
  3. Go to your webhost File Manager. Make sure that you select Show Hidden Files when you select the directory to be opened.
  4. Copy the WordPress Files from your current directory to the subdomain directory created for your subdomain.
    There are 3 folders of wordpress and the rest of the files under your domain that starts with “wp-“. Copy all those including the .htaccess file.
    Select all the WordPress files. Important! When selecting all your WordPress Files, make sure the folders for the subdomains/addon domains, or any other non WordPress folders, are not selected. After selecting all, hold the Ctrl key on the keyboard and click the folders that are not being moved so the are not highlighted blue before copying the files. Otherwise, there will be duplicates of those folders in the testing site.Click Copy at the top right side of the File Manager
    Type the path to the Document Root folder for the Sub Domain.
  5. Create a new database that you will use to for the test site using MySQL Wizard. Click here for the video tutorial of how to create a database. You will need a new database name, username and password.
  6. Copy your current database to your new database. Go to PHPMyAdmin and click the database of your current wordpress site on the left side. (To find out the name of the database, view the wp-config.php file of the website that you are following.) On the right side panel, on the top horizontal menu, click OPERATIONS.  You will find “Copy database” and just enter the name of the new database. Choose Structure and Data, uncheck Create Database, and check ADD TABLE and ADD AUTO_INCREMENT, and check SWITCH TO COPIED DATABASE.  Then click GO.
  7. Configure the Test WordPress wp-config.php file for the dev site. Edit the WP-CONFIG.PHP file of your dev site. Find the following and change the database name, user and password:
    // ** MySQL settings - You can get this info from your web host ** //
     /** The name of the database for WordPress */
     define('DB_NAME', 'newdatabase_name');
     /** MySQL database username */
     define('DB_USER', 'newdatabase_username');
     /** MySQL database password */
     define('DB_PASSWORD', 'passwordgoeshere');
  8. Change the site URL for the test site – Add the following code above the code on number 7. After adding this code, save and exit/close.
    define('WP_HOME','http://dev.yourwebsite.com');
     define('WP_SITEURL','http://dev.yourwebsite.com');
     // ** MySQL settings - You can get this info from your web host ** //
  9. Update image links – update the image links in your dev site through the database PhPMyAdmin.
    Go to your devsite database. On the left side, find the wp_posts and click it (the “wp_” part may be different but it should have the “posts” on the end part.)
    On the right panel, go to SQL.
    On the window below that says RUN SQL, replace the content with the text below:

    UPDATE wp_posts SET post_content=(REPLACE (post_content, 'yourwebsite.com','dev.yourwebsite.com'));

    Don’t forget to replace “wp_posts” with whatever prefix you are using on your database, your live website URL and your dev site URL.
    Click Go.

That’s it.