- Canada's Leading Web Hosting and Domain Name Provider

How to Make a Staging Website by Cloning Your Site in cPanel

Once your website gets to a certain level of success, you may find that you also have to professionalize how you administer your site. One key component to a smoothly running website is a staging site — an exact copy of your site in a “sandbox” environment that only you can see — where you can try new updates, designs, and test features before they are released to the “live” version of your site. 

There are a number of obvious benefits to this. And, it also happens to be quite easy to do using cPanel, which comes with every website hosted by us.

Here are the instructions on how to create a copy of your site, to use as a staging site:

Using WordPress Toolkit

  1. Open WordPress Toolkit in cPanel and expand the detail view for the site you would like to clone. 
  2. Click the Clone tool in the site’s dashboard. When the clone tool opens, select a subdomain and a path to clone the site to. If they don’t exist, WordPress Toolkit will create them for you. 
  3. When you’re finished, click Start at the bottom of the page. WordPress Toolkit automatically copies the site, creates a new database and database user, configures the site to use the database, and creates a new subdomain if necessary. Once it’s done, you access the cloned site as usual. 

Using cPanel in General

To clone a site, you’ll need to:

Create a new folder and copy the site’s files into it. 

  1. Open File Manager, which you can open from the Files section of cPanel’s main page menu.
  2. Select the directory containing the WordPress site you want to clone. 
  3. Click Copy in the toolbar and enter a name for the new directory. To keep things simple, we’ll clone the site into a directory under public_html so that you can access it from a URL such as “example.com/wordpress_two.” 

Export the original site’s database, create a new database for the clone, and import the data into it. 

  1. Open MySQL Databases, which you’ll find under Databases the main page menu. 
  2. Enter a name for the new database under Create New Database and click the Create Database button. 
  3. Next, we export the original database.  We’ll use phpMyAdmin, which is also under Databases in the cPanel menu:
    • Select the original database in the sidebar.
    • Select the Export tab and make sure the Quick export method is selected. The custom method lets you change database export options, but we’ll stick with the defaults. 
    • Click Go.  
  1. This “dumps” the database, downloading an SQL file to your local machine with the information needed to recreate the original site’s database. That’s what we’re going to do next, also using phpMyAdmin. 
    • Select the new database (the one we created in the previous section).
    • Click the Import tab. 
    • In the File to import section, click Choose File and browse to the SQL file you just downloaded. 
    • Click the Go button at the bottom of the page.
  2. The last step in this section is to give the database a user with a password. You can use an existing database user, but we’ll add a new user and give them a unique password. 
    • In cPanel, navigate to the MySQL Databases page. Scroll to the Add New User section. 
    • Under Add New User, enter a username and a strong password. 
    • Click Create User, and then return to the MySQL Databases page.
    • Under Add User to Database, select the new user and the database we created in a previous section. 
    • Click Add, select “All Privileges” on the next page, and confirm the changes.

Configure the clone to work with the new database. 

  1. Open File Manager and select the new site’s directory. 
  2. Select the wp–config.php file. 
  3. Click Edit in the toolbar. 
  4. We need to edit several fields in the MySQL settings section of wp–config.php so that WordPress can access and authenticate with the new database. 
    • Enter the new database name in the DB_NAME field.
    • Enter the user we just created in the DB_USER field.
    • Enter the user’s password in DB_PASSWORD. 
  5. While we have wp-config.php open, we can also tell WordPress about its new URL. There are various ways to do this, but the quickest is to add the following lines, with appropriate changes, to the bottom of the file. 
    • <! – wp:paragraph – >
    • <p>define( ‘WP_HOME’, ‘http://example.com/wordpress_two’ );</p>
    • <! – /wp:paragraph – >
    • <! – wp:paragraph – >
    • <p>define( ‘WP_SITEURL’, ‘http://example.com/wordpress_two’ );</p>
    • <! – /wp:paragraph – >
  6. Don’t forget to click Save Changes when you’re finished. 

As you can see both ways of cloning your site are fairly intuitive, but using the WordPress Toolkit is significantly easier. The WordPress Toolkit comes with every instance of cPanel that comes with your CanSpace Solutions hosting account. If for some reason you can’t locate the toolkit, reach out to us, we’re happy to help!

CanSpace Team

CanSpace Solutions is Canada's leading domain name registrar and web hosting provider. Keep an eye on our blog for expert information on domain names, websites, and running a business online.