The plugin method is recommended for small sites, less important sites, and/or you don’t mind paying for a plugin. Using a plugin can be much faster and easier (fewer steps) but sometimes plugins don’t copy the site as perfectly or they don’t work for certain sites.
Create new WordPress installation on staging domain:
- Log into cPanel > Subdomains, type in subdomain (e.g. “staging”), and let document root field populate naturally. If using sub-domain, please make sure added an A record for it in your DNS settings (Cloudflare) to point to the server IP.
- Then go to cPanel > WordPress manager > new site, choose the subdomain and click [Install]. (In case if you can’t install on your subdomain because it already exists, then go to cPanel > Site Software and delete the site from here first.)
- Log into both your production site and staging site and install whichever cloning/migration plugin you’d like to use (WPvivid is free, UpDraft is paid). Follow their instructions.
- In case you don’t know, popular cloning/migration plugins are: All-in-One Migration (paid), Updraft Plus – Migrator (paid).
- You can even use WP Staging (paid), which is even easier and doesn’t even need the first two steps. It places the staging site in a sub-directory within your main site.
The manual method is recommended for large sites, critical sites, or when you simply need to make sure that the clone is 100% perfect. The manual method is also FREE and won’t cost you anything.
Copy live site files to staging:
- Log into cPanel > Subdomains, type in subdomain (e.g. “staging”), and let document root field populate naturally.
- Go to File Manager, navigate to the folder that has the site you want to copy. Copy all files to the subdomain directory.
- Go to the subdomain directory and edit the wp-config file. First change the database name to a new one, any name you want. Then add the following lines somewhere to specify the staging site URL. (I assume you want HTTPS instead of HTTP, but either would work.)
define( 'WP_HOME', 'https://staging.yourdomain.com' ); define( 'WP_SITEURL', 'https://staging.yourdomain.com' );
Copy live site database to staging database:
- Go to cPanel > phpMyAdmin.
- Select the live site database from the left, then click “Export” tab. (File will download to your computer.) Click [GO].
- Then go to cPanel > MYSQL Databases, and Create New Database using the new name you chose above. Also add the database user to the new database (giving full permissions).
- Go back to phpMyAdmin (refresh the page if needed), and choose the new database from left side.
- Then click “Import” tab, choose downloaded database file from your computer and click [GO].
Create DNS record for staging domain:
- Log into Cloudflare (or if you have any other DNS management tool).
- Create an A record for your subdomain (e.g. “staging”), and point it to our server IP. If you don’t know the IP, it’s probably the same as your regular domain IP (assuming they’re on the same server).
- New DNS records can take anywhere from minutes to hours to fully propagate. Cloudflare usually takes only minutes. You can check the current domain propagation status at DNSChecker.org or try browsing the staging URL every few minutes.
Manually updating URL’s on staging domain:
- Log into WP admin for staging site.
- Install “Better Search Replace” plugin, and then run it from “Tools > Better Search Replace”.
- Search for “yourdomain.com” (or “www.yourdomain.com”) and replace with “staging.yourdomain.com”. And select all tables. If you get the page error, try selecting only a few at a time.
- Go to Settings > Permalinks, and hit SAVE “twice”.