Jul 28, 2021
WordPress Staging Environment: A Beginner’s Guide to Staging Sites
When modifying a site, you need to ensure the changes made don’t affect your website negatively. Accidents happen, sites crash, so you’ll need a safe environment where you can test everything first before publishing it online.
To ensure safe and efficient modifications, you can create a WordPress staging site.
This tutorial will show you how to create a staging environment for developing and modifying your WordPress site securely without affecting your original site.
What Is WordPress Staging?
A WordPress staging environment acts as a duplicate of your website. Using it, you can test any changes you plan to implement to a WordPress site, such as updating themes, plugins or completely remaking the website.
Keep in mind that a WordPress staging site is used for development purposes only and is not accessible by the public or search engines.
Developers usually use multiple environments for the same website to ensure a site is running smoothly. A staging site is a bridge between the development site, where a developer writes code and performs initial testing, and the production site – the live website that the site visitors see.
Why Use WordPress Staging?
A WordPress staging site helps you to test any changes made to a website safely.
With it, you can modify a site without crashing it or altering the functionality of the live version. This helps to avoid downtime and poor user experience for the visitors.
However, using a WordPress staging site comes with its pros and cons, such as:
- Risk-free environment. A safer environment to modify your site without risking the functionality of the live website.
- Early prevention of errors. It helps discover critical issues and system crashes before the site goes live.
- Flexible setup. It’s possible to set it up locally or online, depending on your preferences.
- The best output possible. Allows you to build a better site since you can test everything thoroughly before launching it.
- Steep learning curve. If you’re a complete beginner, creating a WordPress staging site can seem somewhat challenging at first.
- Additional cost. If you prefer to have the staging site online, it may include additional plugin or hosting fees.
- Time-consuming. You will spend some time testing the changes on the WordPress staging site and reapply those same changes to the live version of the site.
Setting Up a WordPress Staging Site
One easy way to create a staging site is to use WordPress hosting that includes a staging tool. It typically only requires a few clicks, which makes it easy to set up even for beginners.
If your hosting provider doesn’t offer this feature, there are two other ways to create a staging site for WordPress – doing it manually or by using a plugin. Let’s go over each method.
How to Create a WordPress Staging Environment Manually
If you prefer to create a staging site using the manual method, you’ll have to access your hosting account’s control panel.
Manually creating a staging site requires configuring code and database settings. While this requires some technical knowledge, it also allows you to make more complicated modifications.
Here is a step-by-step guide that will show you how to create a staging environment manually:
1. Create a Subdomain
First, you need to create a subdomain for your staging environment. It will act as a subsection of your main domain that can be used to create a separate section of your website.
Since the subdomain functions independently from the main domain, it can also host a secondary website.
For example, if a domain is mysite.com, we can use staging.mysite.com as a subdomain URL for the staging environment.
Here’s how to create a subdomain for a staging site on the hPanel:
- Open the hPanel and navigate to Domains -> Subdomains.
- On the Create a New Subdomain section, enter the subdomain name.
- A new folder will automatically be created in your home directory /public_html under the same name as your subdomain. If you want to use a custom name for the folder, tick Custom folder for subdomain option, then click Create.
- Once you create the folder, you’ll see the subdomain in the List of Current Subdomains section. Make sure to delete it from this section when you finish using the staging site.
2. Copy Your WordPress Website Files to the New Subdomain
The second step is to copy all your WordPress site’s files to your newly-created subdomain.
To do so, use either a File Manager or an FTP client. The process is the same on both platforms.
The File Manager is a file management tool that allows you to upload, extract, and create files and folders. It also helps to take care of other file management-related tasks such as assigning permissions.
In this tutorial, we will copy the live site files by using the hPanel’s File Manager. If you have an FTP account, you can copy the files using an FTP client like FileZilla.
Follow these steps to copy your WordPress site files to your subdomain:
- Open your hPanel and go to Files -> File Manager.
- A new window will open, and you’ll see the directory of folders and files of your website. In this example, the files will be in the public_html folder. Click on it to open the folder.
- Next, move the files to public_html/staging/. Select all the folders and files inside except the staging folder. Click the Copy icon on the top toolbar.
- A confirmation message will appear. It will show your file selection and the copy destination. Click Change to set the Destination to the staging folder. Click Copy.
- Once the Copy file window disappears, see inside the staging folder to ensure all your website files and folders are there.
3. Make a Copy of the Database
Now you need to duplicate your production site’s existing database. Use phpMyAdmin to copy an existing database to your staging folder.
After successfully creating a duplicate database, make sure to tick all the permissions, so your staging website has the same database access as your live website.
4. Configure the Subdomain’s config.php File
On your File Manager, navigate to your staging folder. In this example, open public_html -> staging -> wp.config.php.
- Double-click the wp.config.php file, and you’ll see this pop-up window:
- Scroll down until you find a line of code that says “MySQL settings – You can get this info from your web host.“
- Right above it, paste these two code snippets:
- Change “subdomain” to your staging subdomain name and “domain” to your original WordPress domain. In this example, the URL will be http://staging.mysite.com.
- On the same pop-up window, scroll down a couple of lines and find two code snippets that say DB_NAME and DB_USER.
Change the name next to DB_NAME into your staging site’s database name and the name next to DB_USER into your staging site’s username.
Your staging environment is now ready for use.
To deploy the changes you have made to your staging environment to your live site, copy the staging database into the live site database.
Don’t forget to copy all files from the staging subdomain folder to the original site folder too.
How to Create a WordPress Staging Environment Using WP Staging
If making a staging site manually seems too complicated, a staging site plugin might be the right choice for you.
Before you create a staging site using WP Staging, decide whether to set up a staging website on a subdirectory of your live site, a subdomain, or a different domain.
In this tutorial, we’ll show you how to create a WordPress staging site on a subfolder.
1. Create a New Staging Site in a Subfolder
The easiest and fastest way to create a staging site with WP Staging is by using a subfolder. This option is set as a default in both free and premium plugin versions.
- On your WordPress admin sidebar, navigate to WP Staging -> Sites -> CREATE NEW STAGING SITE.
- Enter the name of your staging site in the Staging Site Name field. In this example, your staging site URL will be https://mysite.com/staging.
The Advanced Settings are only available for WP Staging Pro users. This section provides more advanced features, like the ability to create a clone site and save it to a custom destination directory.
2. Choose Which Database Tables to Include and Exclude
In some cases, you may want to exclude specific files and database tables from the cloning process. Excluding heavy content, such as tables created by web statistics plugins can increase the cloning process’s speed.
You can make these adjustments in the Database Tables and Files sections of the plugin.
Keep in mind that you should not tamper with any additional settings if you’re not sure about what you’re doing. If in doubt, simply leave everything in default.
3. Start the Cloning Process
Once you adjust the DB Tables and Files, click the START CLONING button.
This process may take a few minutes, depending on the size of your website.
Once WP Staging has finished creating a staging website, it will inform you about the completion and display the staging site’s URL. You can click the Open staging site button and directly access the newly created staging environment.
Another way to access the staging site is to navigate to WP-Staging -> Sites from your WordPress dashboard.
WP Staging allows you to create as many staging sites as you have space for.
Other WordPress Staging Plugins
Aside from WP Staging, there are three more good-quality staging site plugins on the market.
All-in-One WP Migration migrates all WordPress website files, including the database, plugins, themes, and media files. This plugin provides a tool to upload your site’s files to a different location by simply dragging and dropping them into WordPress.
All-in-One WP Migration’s key features include:
- Bypass size restrictions. Uploads or downloads your site data in chunks, overcoming any file size restrictions.
- All-in-one login credentials. Uses the same username and password for logging in to the staging site as your production site.
- Find-and-replace during export. Capable of finding and replacing operations on the database during the export process.
- Selective migration. It provides an option to exclude specific files such as databases and spam comments, making copying your WordPress website more efficient.
All-in-One WP Migration is a free plugin. To add more advanced features such as cloud storage migration and larger-size backups, you’ll need to buy premium extensions.
Duplicator is a plugin that clones, backs up, and migrates websites between hosts and domains, letting you easily migrate your site to any staging location.
It does so by creating a package consisting of a ZIP file of your site’s database, content, plugins, themes, and other WordPress files.
Duplicator’s key features include:
- Preconfigured sites. The Duplicator package enables you to avoid repetitive setups. Configure your production site and bundle it up into a Duplicator package. This way, you won’t have to configure everything from scratch on your staging site.
- Recovery points. It lets you quickly restore your system to a known and safe state anytime you make any mistakes or perform bad updates.
- Scheduled backups. The premium version offers two backup options – immediate or scheduled for a specific time.
- Supports large sites. Migration in a package form makes Duplicator capable of handling larger websites effectively.
There are two types of Duplicator plugins: the free Duplicator Lite and the premium Duplicator Pro. These plugins are separate, so you can’t upgrade Duplicator Lite. If you want to use the Duplicator Pro, you’ll have to purchase it separately.
The Duplicator Pro comes with yearly plans that start at $69/year or a lifetime plan for $549.
WP Stagecoach uses a database merge feature to apply the changes you made in the staging environment to the live site. This means it doesn’t overwrite your database during the importing process, which is a good security feature.
WP Stagecoach also lets you make changes to your live site while also working on your staging site at the same time.
This plugin is especially suitable for eCommerce sites or other websites that have their content or database regularly updated. It allows you to troubleshoot or modify your site while keeping the content, orders, or registrations running.
WP Stagecoach key features include:
- One-click setups. You can set up a staging site or push changes to your live site with one click. This is especially beneficial for non-technical users since they can skip the technical steps, making their work faster and easier.
- Password-protected staging site. Your staging site is located on your server and protected by a password so that you can show it to your clients or teammates safely.
- Selective migration. You can select which changes you want to upload to your live site.
- Supports large websites. It also works well with multiple websites. This plugin can import site files in chunks, which is helpful if your server is slow.
- Recovery provision. When you accidentally make a mistake, WP Stagecoach provides a link to revert to your old site.
WP Stagecoach is a paid plugin with various plan options starting from $99/year.
WordPress staging environments provide you with a safe place to modify your website.
Unlike production sites, staging sites won’t be indexed by the search engines, and visitors won’t be able to access them. Meaning, you don’t have to worry about making mistakes and crashing your site.
There are two methods to create a WordPress staging site – by manual setup or using a plugin. Evaluate your technical skills and choose a method that you feel the most comfortable with.