Create staging site on subdomain

PLUGIN METHOD

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:

  1. 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.
  2. 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.)
  3. 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.
  4. In case you don’t know, popular cloning/migration plugins are: All-in-One Migration (paid), Updraft Plus – Migrator (paid).
  5. 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.

MANUAL METHOD

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:

  1. Log into cPanel > Subdomains, type in subdomain (e.g. “staging”), and let document root field populate naturally.
  2. Go to File Manager, navigate to the folder that has the site you want to copy. Copy all files to the subdomain directory.
  3. 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:

  1. Go to cPanel > phpMyAdmin.
  2. Select the live site database from the left, then click “Export” tab. (File will download to your computer.) Click [GO].
  3. 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).
  4. Go back to phpMyAdmin (refresh the page if needed), and choose the new database from left side.
  5. Then click “Import” tab, choose downloaded database file from your computer and click [GO].

Create DNS record for staging domain:

  1. Log into Cloudflare (or if you have any other DNS management tool).
  2. 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).
  3. 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:

  1. Log into WP admin for staging site.
  2. Install “Better Search Replace” plugin, and then run it from “Tools > Better Search Replace”.
  3. 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.
  4. Go to Settings > Permalinks, and hit SAVE “twice”.

Looking for ultra-fast WordPress hosting?

Learn More About JVPS

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *