Knowledgebase

Word Press: Creating A Staging Site  Print this Article

Step 1: Create a subdomain through cPanel

First, you’ll need to create a subdomain to actually house your staging site. Go to cPanel and find the Subdomains option. Your cPanel might be styled differently, but the actual options should be the same:

How to set up a WordPress staging site

Then, create a subdomain named “staging” or something similar:

Step 2: Create an FTP account for your new subdomain

Next, you need to create a new FTP account for your subdomain. This ensures everything is always kept separate.

Find the FTP Accounts option and click on it:

Then enter the new account details. Make sure the Directory matches the directory (Document Root) for your subdomain:

Step 3: Upload WordPress files to staging site

Next, you’ll need to use that new FTP account to upload your site’s files.

First, download the latest version of WordPress and upload that:

Then, you need to also copy over these three folders from your existing WordPress site:

  • .../wp-content/uploads
  • .../wp-content/themes
  • .../wp-content/plugins

Upload those to your staging site as well. If your folders are especially large, you might be able to use cPanel’s File Manager to speed up the process. Otherwise, FTP is totally fine. I personally use FTP – it just might take some time to run through large folders.

Step 4: Export / Import your database

Next, you’ll need to export your live site’s database and import it to your staging site.

To do that, I like a dedicated plugin called WP Migrate DB. Install and activate it, then run it by going to Tools → Migrate DB.

The plugin will automatically update all of the file paths in your database to point to your new staging site URL. This is absolutely essential to ensuring your staging site actually works. Just make sure you enter the same directory path and URL that you used when you created your subdomain:

Then export the database.

Next, you need to create a new database for your staging site and import all of the data. Head back to cPanel and find the MySQL Databases option:

Click it and create a new database:

You’ll also need to create a new database user:

And give that user access to your new database:

Then, go to PHPMyAdmin. Find the database you just created, click Import, and choose the file that WP Migrate DB exported:

Then click Go to import your database data.

Step 5: Edit wp-config.php to point to new database

Last step! You need to edit the wp-config.php file on your staging site to use your new database details and username.

Also, make sure the database prefix matches the one used on your live site. You probably won’t need to change anything here – but it’s possible depending on what prefix your live WordPress site uses. For example, my live test site uses “wpov” as the database prefix, so I had to make that change.

If you’re editing the “wp-config-sample.php” file, make sure to rename it to just “wp-config.php”. Then upload it back to your server over FTP.

Step 6: Log in and restrict access to your staging site

If all went well, you should now be able to log in to your staging site using the exact same username/password as your live site.

There’s really just one more thing you need to do:

Restrict access to your site.

Start by going to Settings → Reading and choosing the Discourage search engines from indexing this site box. That will at least stop Google from indexing your site.

If you want to restrict access even further, you can use a plugin called Hide My Site. In order to access any part of your site, visitors will first need to enter a password. You can still share your development site if needed by sharing the password, but strangers won’t be able to access your site.

How to push changes to your live site

If you’re using a staging environment set up through your host, you can usually push changes live by clicking a button.

It’s not quite that simple with a manual system. While there are ways to set up automated deployment from your staging site to your live site, I don’t think that’s a good idea.

You’re always risking something going wrong during the transition, and there really is a lot that could go wrong. For example, you might get just part of your changes deployed (= crashed site), or some untested changes might get deployed too quickly (= crashed site), and etc.

It’s safer to simply roll out changes manually once you’ve thoroughly tested them on your staging site.

Wrapping things up

Setting up a WordPress staging site is a great way to play around with changes before you push them live. If you want the absolute easiest way to run a staging site, pay for a host which offers built-in staging sites.

But if that’s not an option right now, setting up your own WordPress staging site isn’t that difficult. WP Staging is great for a simple testing area, while manually creating a staging site on a subdomain will give you more flexibility.

Was this answer helpful?

Related Articles

WordPress: sending emails via SMTP
Configuring the sending of e-mails via SMTP in WordPress guarantees us that the messages from our...
WordPress: Installing WordPress using Installatron
From cPanel, click on Installatron Applications InstallerClick on WordPressClick on install this...