For website testing or development purposes, you can setup the site on your local machine using certain server environment software, such as MAMP, WAMP, XAMPP, etc. See how to create a WordPress site on Mac using XAMPP for free. Or setup a WordPress site on Windows PC using WAMP, another open source software you can use to create websites on local computer.
But what if you already have the site running on production server? Do I have to backup the live site to computer? That would be an option. But the easier way is to make a copy of the live site for testing or development purposes without downloading it to your local machine. This article will outline the steps to duplicate a WordPress site online.
Please note that these directions are made for duplicating a single-site WordPress installation other than a multi-site installation.
Step 1. Copy website files to new location
Log on your hosting control panel. In this article, we will use a cPanel web hosting in the demo. In cPanel, go to the Files section, click to open File Manager. Make sure to show hidden files in cPanel File Manager.
Select all WordPress files or the whole folder in File Manager, then click Copy at the top left side of the File Manager, or right click on the files or folder, choose Copy from the contextual menu. You will then be prompted to enter the file path that you want to copy these files or folder to. Type the path to the new location to save the WordPress files to.
Step 2. create WordPress database
Go to create a MySQL database in cPanel from cPanel > Database Tools > MySQL databases. Make sure to give the new database a new name. You can add the same user to the new database. Creating a new user and adding it to the new database will also work, but requires extra steps.
Step 3. Import data to new WordPress database
The newly created MySQL database is empty without any data. We need to export data from existing database and import it to the new one. This can be done using the phpMyAdmin tool which is also pre-installed in cPanel. See how to backup MySQL database in cPanel here.
In phpMyAdmin, select the WordPress database, choose Export to download a copy of your database from MySQL server to your local computer. Then open the new WordPress database in cPanel, choose Import and restore the MySQL database through phpMyAdmin in cPanel
Step 4. Edit database configuration for new WordPress site
The wp-config.php file is the WordPress configuration file. You need to update the database information accordingly. Remember that we created a new database with a new name. Update the database name in the configuration file. If you created new database user, you need to update the database username and password as well. Follow this tutorial to create database connection for WordPress site.
Step 5. Create sub-domain for the test site
You need to test the website using a temporary URL. A sub-domain is ideal for website testing and development purposes. Check out these steps to create a sub-domain on Bluehost hosting server, just as an example.
Make sure to redirect the sub-domain to the location or directory where you have copied the WordPress site files to.
Step 6. Change site URL for the test site
The WordPress site URL or domain is saved in its database. We need to replace it with the new sub-domain or URL we have created above. You can follow this guide to change WordPress domain name or this tutorial to change WordPress site URL. Since you can’t access the WordPress test site yet, you will need to update the site URL from its database via phpMyAdmin first.
Lastly you can choose to update the image URLs from the database. This step is not mandatory when you clone the WordPress site for testing purpose. Thus we will not discuss this issue further in this article.