How to Create a WordPress Staging Site (and Why You Need One)
Have you ever updated a plugin on your WordPress site and had the screen go white? You didn’t change any code, but the site goes pear-shaped right in front of you, all from one little plugin. Panicked, you try a few things and manage to get it back online, only to see a distorted layout. Not long after that, site visitors start sharing witty commentary about their experience and depending on the nature of your site, you take a hit in the revenue department.
Fortunately, website owners can completely avoid situations like this by testing updates and changes on a WordPress staging site.
Also referred to as a development or testing site, a WordPress staging site is an offline clone of your website. You can use this duplicate site to perform testing and make changes in an environment hidden from visitors. Working in a staging site eliminates any downtime that results from plugin malfunctions, page crashes or broken code.
Reasons to Create a WordPress Staging Site
A staging site is often used while building a new website, but it can also come in handy when updating and improving an existing site. By working in a staging environment, you ensure that the experience of your visitors isn’t disturbed as you make edits. The original site continues to work normally until a decision is made to push those changes live.
Other benefits of using a WordPress staging site include:
- It allows you to troubleshoot plugin issues without spreading the problem to your live site
- Having a staging site eliminates the negative impact of a crashed website on conversion and sales
- Website owners are empowered to thoroughly test every element at their own pace without the time constraint of having the actual site in maintenance mode
Despite the many benefits of using a WordPress staging site, you won’t have much leverage unless you know how to set one up. So, let’s move forward and learn to develop a WordPress staging site.
Setting Up a WordPress Staging Environment
There are many options for creating a WordPress staging site, and we’re going to explore a few of the more popular choices below. This way, you can assess the pros and cons of each and pick the one that best suits your needs.
1. Create a WordPress Staging Site Using Your Web Host
Most managed WordPress hosts offer one-click staging environments or command-line tools as part of their packages. The exact steps to set up a staging environment may vary slightly across hosts, but the process is largely similar. Pagely, for instance, offers a command line tool named “Pagely Sync” that enables you to easily clone your website.
Here’s a step-by-step breakdown of how to create a staging site on Pagely.
- Use the Atomic core dashboard to log in to your Pagely account.
- Select “Deploy New App” to open a staging site.
- Choose a name for the staging site. Anything along the lines of staging.mywebsite.com should work fine.
The information for the app can be accessed by visiting “Sites > All Sites,” find your new app and click “App Details.” The temporary Pagely URL that’s presented is your new staging website.
Pagely’s current staging set up can sync databases and files, with the additional capability to neglect files and/or tables. It also has the ability to perform plain site renaming, but the URLs don’t undergo database rewriting since that can cause issues. Pagely’s staging feature is available to users on its VPS and Enterprise plans.
Creating a demo site on Pagely is simple and straightforward, making it easy for even the most non-technical people to create a staging environment. Your host may or may not have this option, so check with support – and tell ’em Pagely sent ya. 😉
2. Build a WordPress Staging Site Manually
A more hands-on approach involves creating a WordPress staging website manually. Beginners are likely to find this option challenging, and it’s best suited for advanced WordPress users with a knowledge of MySQL database operations. The benefit of adopting this approach is that it gives you total control over the staging setup.
Here’s how to create a WordPress staging site manually:
- Create a sub-domain on the main domain by logging into your cPanel or another control panel. A sub-domain enables website owners to run their staging site in a separate folder, which leaves the main database and its contents unaffected. Click “sub-domains” under the “domains” section.
- Enter a name for your sub-domain, then use the drop-down menu to select your actual domain. When you do so, the “document root” text box inside the cPanel should fill in automatically and show a location based on your sub-domain. It will be something like public_html/staging.
- Click “Create” once you’ve finished the previous steps. It should proceed, and display the sub-domain in a table. It can also be verified through a web browser and should appear like this:
- The next step is to create a dedicated FTP account for the staging site. It will only provide access to the staging environment to secure against accidental modifications to the live site.
- Go to “FTP Account” in cPanel and complete the fields in the “Add FTP Account” section. The “Directory” should be similar to the directory you selected while creating your sub-domain.
- Select “Create FTP Account” to create a brand new account. This will only provide access to the specified directory and not the entire server.
- After the sub-domain has been created, copy the data from the actual site to the staging one. To do so, go to cPanel and log into “phpMyAdmin” and choose the database of the live site. Click “Operations” in the menu bar after doing so.
- Search for the text box named “Copy Database To” and enter the staging database’s name in it. If you didn’t create a database for your staging website, check “CREATE DATABASE before copying” and name it to something like sample_staging. Both the data and structure needs to be copied and no settings should be changed. Select “Go” to run the duplicate.
- After the copying of the database finishes, select it from the left of the sidebar. Then the newly copied database will be launched by phpMYAdmin. Afterwards, click “SQL” tab in the phpMYAdmin menu bar.
- 10. All the references on your actual site should be copied to the staging site to ensure everything is in order. Run these SQL queries next:
First query: UPDATE wp_options SET option_value = REPLACE(option_value, ‘ORIGINAL_URL’, ‘NEW_URL’);
Second query: UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, ‘ORIGINAL_URL’, ‘NEW_URL’);
Third query: UPDATE wp_posts SET guid = REPLACE(guid, ‘ORIGINAL_URL’, ‘NEW_URL’);
Fourth query: UPDATE wp_posts SET post_content = REPLACE(post_content, ‘ORIGINAL_URL’, ‘NEW_URL’);
These queries should replace the following values as you enter them in the SQL query box:
- NEW_URL: the new URL, the one created by your staging site earlier, needs to be filled. Write http:// before the URL.
- ORIGINAL_URL: this is the URL of the original site. It can be found through the WordPress Admin area by going to Settings > General > WordPress Address (the URL).
- Wp_: Replace wp_ with any custom prefix present on database tables.
Click “Go” to start queries and wait for the confirmation message saying that the process is complete. Once your database is copied, you can proceed with copying things like themes and plugins. Go to WordPress.org and download a new copy of the WordPress software, and upload its contents to the staging environment without running WordPress install.
After WordPress is uploaded, you can start copying plugins, themes, and media files. These are the folders that have to be copied:
If you haven’t stored a lot of content in these folders, you can also use your FTP client to download them from your actual website and upload them in staging. For folders with a larger amount of content, use the native file manager provided by cPanel because it copies folders on the server directly. These folders need to be copied to the staging folder i.e. /public_html/staging/wp-content/.
Once all that is done, you can connect the WordPress staging installation to the database you copied before. Open the staging environment, through the sub-domain created earlier. If the staging directory is missing a wp-config.php file, your database connection details may be asked for in order to create one. But if there’s one already there, edit it and put in the new staging database connection info.
WordPress should then connect to the staging database, detect WordPress was successfully installed, and ask you to log in. The login credentials will be the same as on your actual website. You will now have a staging site that’s independent from your live website for testing purposes.
3. Use a Plugin to Develop a WordPress Staging Site
The plugin approach is the easiest one among all options. Through the WordPress admin area, you can install a staging plugin that handles the process of copying the database between sites. Here are three recommended plugins:
All-in-One WP Migration
The All-In-One WP Migration plugin is simple to use and it allows you to export a duplicate copy of your site, which is required for testing. Install this plugin and go to “All-In-One WP Migration” > “Export” from the admin area. Choose “find and replace” if you want to modify anything, like the name you want to use for the staging website. You can also take out spam comments to shrink export size.
While we have you...Learn More
Did you know Pagely has a number of managed solutions to help big brands scale WordPress?
After saving the export files, import them to the new installation on the sub-domain. The plugin first needs to be installed on the import site, which can be done by choosing “All-In-One WP Migration” > “Import” in the admin area of the staging site. The export file can be dragged-and-dropped into the import area. After the import completes, use the original site’s credentials to log in, and click “Save” twice to update permalinks. You’ll now have a staging environment at your disposal.
WP Staging’s rating indicates that its a go-to plugin for setting up a staging site. Search for it through the admin area and install it. Next, go to “Plugins” > “Staging” > “Create New Staging Site” to begin. Give a name to your staging site and a sub-directory will be created for it under your current WordPress website.
Agree to the scan of database tables and files and configure any advanced option. Select “Start Cloning” and wait for the process to complete. After completion, you can click the button and use the admin credentials that you used on the original website to log into the staging version of it. Using WP Staging is one of the fastest routes you can take to create a WordPress staging website.
Short on time and looking for a plugin that allows you to create a staging site within minutes? Look no further than WP Stagecoach. Install it and then click “WP Stagecoach” from the admin area of your WordPress website to set a URL for the staging site. You may also be asked to create a password. Then click “Ride the Stagecoach” to build the staging environment, which you can access using the same username and password that you use for your original website.
WP Stagecoach also enables you to pick which changes to import on the staging site; you can import some or all of your database changes. There is also an option to password-protect the staging area. SSL is activated on every staging site. In addition, WP Stagecoach runs the site on its own server. Although this saves you the hassle of hosting the staging area on your site, it also means you get a different environment than the live site, which can sometimes cause technical difficulties.
The thought of creating a WordPress staging website can be stressful for many website owners, but there are many options that you can experiment with based on your tech level. If you want to ensure that changes and updates don’t impact your live website, it’s important to conduct all of your testing in a private, offline environment.
What’s your preferred option for creating a WordPress staging website?