<em>We're currently updating this piece to be more accurate. In the mean time, <a href="https:\/\/support.pagely.com\/hc\/en-us\/articles\/115001622571-Creating-a-Staging-Environment" target="_blank" rel="noopener noreferrer">check out this piece<\/a> for current best practices from our Docs team.<\/em>\r\n\r\nHave 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.\r\n\r\nIt happens.\r\n\r\nFortunately, website owners can completely avoid situations like this by testing updates and changes on a <strong>WordPress staging site.<\/strong>\r\n\r\nAlso 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 <a href="https:\/\/pagely.com\/blog\/configuring-site-zero-downtime\/" target="_blank" rel="noopener noreferrer">downtime<\/a> that results from plugin malfunctions, page crashes or broken code.\r\n<h2>Reasons to Create a WordPress Staging Site<\/h2>\r\nA 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.\r\n\r\nOther benefits of using a WordPress staging site include:\r\n<ul>\r\n \t<li>It allows you to troubleshoot plugin issues without spreading the problem to your live site<\/li>\r\n \t<li>Having a staging site eliminates the negative impact of a crashed website on conversion and sales<\/li>\r\n \t<li>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<\/li>\r\n<\/ul>\r\nDespite 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.\r\n<h2>Setting Up a WordPress Staging Environment<\/h2>\r\nThere 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.\r\n<h2>1. Create a WordPress Staging Site Using Your Web Host<\/h2>\r\nMost <a href="https:\/\/pagely.com\/blog\/what-is-managed-wordpress-hosting\/" target="_blank" rel="noopener noreferrer">managed WordPress hosts<\/a> 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 "<a href="https:\/\/support.pagely.com\/hc\/en-us\/articles\/203115924-Cloning-Sites-with-Pagely-Sync" target="_blank" rel="noopener noreferrer">Pagely Sync<\/a>" that enables you to easily clone your website.\r\n\r\nHere's a step-by-step breakdown of how to create a staging site on Pagely.\r\n<ol>\r\n \t<li>Use the Atomic core dashboard to log in to your Pagely account.<\/li>\r\n \t<li>Select "Deploy New App" to open a staging site.<\/li>\r\n \t<li>Choose a name for the staging site. Anything along the lines of staging.mywebsite.com should work fine.<\/li>\r\n<\/ol>\r\n<img class="aligncenter size-full wp-image-9366" src="https:\/\/pagely.com\/wp-content\/uploads\/2017\/05\/p1-1.png" alt="Create a Staging Site Using Pagely " width="600" height="321" \/>\r\n\r\nThe 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.\r\n\r\n<img class="size-medium_large wp-image-9389 aligncenter" src="https:\/\/pagely.com\/wp-content\/uploads\/2017\/05\/atomic-staging-1-730x215.png" alt="Atomic Staging" width="730" height="215" \/>\r\n\r\nPagely'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 <a href="https:\/\/pagely.com\/plans-pricing\/wordpress-vps-hosting\/" target="_blank" rel="noopener noreferrer">VPS<\/a> and <a href="https:\/\/pagely.com\/plans-pricing\/enterprise-wordpress-hosting\/" target="_blank" rel="noopener noreferrer">Enterprise plans<\/a>.\r\n\r\nCreating 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. ;)\r\n<h2>2. Build a WordPress Staging Site Manually<\/h2>\r\nA 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.\r\n\r\nHere's how to create a WordPress staging site manually:\r\n<ol>\r\n \t<li>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.<\/li>\r\n<\/ol>\r\n<img class="aligncenter size-medium wp-image-9372" src="https:\/\/pagely.com\/wp-content\/uploads\/2017\/05\/p6-1-600x183.png" alt="Setting up staging" width="600" height="183" \/>\r\n<ol start="2">\r\n \t<li>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<em> public_html\/staging.<\/em><\/li>\r\n \t<li>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:<\/li>\r\n<\/ol>\r\n<img class="aligncenter size-medium wp-image-9373" src="https:\/\/pagely.com\/wp-content\/uploads\/2017\/05\/p7-600x239.png" alt="Staging technical " width="600" height="239" \/>\r\n<ol start="4">\r\n \t<li>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.<\/li>\r\n \t<li>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.<\/li>\r\n<\/ol>\r\n<img class="aligncenter size-full wp-image-9374" src="https:\/\/pagely.com\/wp-content\/uploads\/2017\/05\/p8.png" alt="" width="495" height="339" \/>\r\n<ol start="6">\r\n \t<li>Select "Create FTP Account" to create a brand new account. This will only provide access to the specified directory and not the entire server.<\/li>\r\n \t<li>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.<\/li>\r\n \t<li>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 <em>sample_staging<\/em>. Both the data and structure needs to be copied and no settings should be changed. Select "Go" to run the duplicate.<\/li>\r\n \t<li>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.<\/li>\r\n<\/ol>\r\n<img class="aligncenter size-medium wp-image-9375" src="https:\/\/pagely.com\/wp-content\/uploads\/2017\/05\/p9-600x171.png" alt="Manually create a staging site" width="600" height="171" \/>\r\n<ol start="10">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:<\/ol>\r\n<strong>First query:<\/strong> UPDATE wp_options SET option_value = REPLACE(option_value, 'ORIGINAL_URL', 'NEW_URL');\r\n<strong>Second query:<\/strong> UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'ORIGINAL_URL', 'NEW_URL');\r\n<strong>Third query:<\/strong> UPDATE wp_posts SET guid = REPLACE(guid, 'ORIGINAL_URL', 'NEW_URL');\r\n<strong>Fourth query:<\/strong> UPDATE wp_posts SET post_content = REPLACE(post_content, 'ORIGINAL_URL', 'NEW_URL');\r\n\r\nThese queries should replace the following values as you enter them in the SQL query box:\r\n<ul>\r\n \t<li>NEW_URL: the new URL, the one created by your staging site earlier, needs to be filled. Write <em>http:\/\/<\/em> before the URL.<\/li>\r\n \t<li>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).<\/li>\r\n \t<li>Wp_: Replace <em>wp_<\/em> with any custom prefix present on database tables.<\/li>\r\n<\/ul>\r\nClick "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 <a href="https:\/\/wordpress.org\/" target="_blank" rel="noopener noreferrer">WordPress.org<\/a> and download a new copy of the WordPress software, and upload its contents to the staging environment without running WordPress install.\r\n\r\nAfter WordPress is uploaded, you can start copying plugins, themes, and media files. These are the folders that have to be copied:\r\n<ul>\r\n \t<li>Wp-content\/plugins<\/li>\r\n \t<li>Wp-content\/themes<\/li>\r\n \t<li>Wp-content\/uploads<\/li>\r\n<\/ul>\r\nIf 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. <em>\/public_html\/staging\/wp-content\/<\/em>.\r\n\r\n<img class="aligncenter size-medium wp-image-9376" src="https:\/\/pagely.com\/wp-content\/uploads\/2017\/05\/p10-600x288.png" alt="Staging site is publicly inaccessible " width="600" height="288" \/>\r\n\r\nOnce 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 <em>wp-config.php<\/em> 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.\r\n\r\nWordPress 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.\r\n<h2>3. Use a Plugin to Develop a WordPress Staging Site<\/h2>\r\nThe 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:\r\n<h2>All-in-One WP Migration<\/h2>\r\nThe <a href="https:\/\/servmask.com\/" target="_blank" rel="noopener noreferrer">All-In-One WP Migration<\/a> 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.\r\n\r\n<img class="aligncenter size-medium wp-image-9367" src="https:\/\/pagely.com\/wp-content\/uploads\/2017\/05\/p3-600x301.png" alt="Plugins To Create A WordPress Staging Site" width="600" height="301" \/>\r\n\r\nAfter 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.\r\n<h2>WP Staging<\/h2>\r\n<a href="https:\/\/wpstagecoach.com\/" target="_blank" rel="noopener noreferrer">WP Staging<\/a>'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.\r\n\r\n<img class="aligncenter size-full wp-image-9368" src="https:\/\/pagely.com\/wp-content\/uploads\/2017\/05\/p4.png" alt="The Easy Way To Create A Staging Site" width="600" height="427" \/>\r\n\r\nAgree 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.\r\n<h2>WP Stagecoach<\/h2>\r\nShort on time and looking for a plugin that allows you to create a staging site within minutes? Look no further than <a href="https:\/\/wpstagecoach.com\/" target="_blank" rel="noopener noreferrer">WP Stagecoach<\/a>. 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.\r\n<img class="aligncenter size-medium wp-image-9369" src="https:\/\/pagely.com\/wp-content\/uploads\/2017\/05\/p5-600x348.png" alt="WordPress Staging Site For Non-Technical Users" width="600" height="348" \/>\r\n\r\nWP 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.\r\n<h2>Conclusion<\/h2>\r\nThe 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.\r\n\r\nWhat's your preferred option for creating a WordPress staging website?