Using a staging environment is critical to the stability of your site. By testing your site on a staging environment before making it live in production, you can easily identify potential issues without impacting existing users.
In this article, we'll show you how to create a staging site and use the Pagely Sync tool to clone your current single instance production site over to your new staging environment.
Note: This article does not account for multisite so if you need to clone a multisite network please do contact support.
Creating a Staging Site
Creating a new site inside the Atomic control panel is easy. Here’s how to do it:
- Start by logging into your Atomic control panel.
- On the left side main menu, click on Apps.
- At the top right of the Apps page, click on the New App button.
- Fill in the Primary Domain field with the domain you’ll want to use. Typically, this is something like staging.example.com.
- Finally, click the Create App button to create your new staging site.
Your staging site is now created and ready to use. Since it’s a freshly created app, you’ll still need to add your own content to it. Follow along in the next section to learn how to clone your existing production site over to your new staging environment.
Cloning from Production to Staging
Now that you’ve created a staging environment, it’s time to clone over a copy of your site to it.
- Begin by logging into your VPS via SSH.
- To clone your production site over to your staging environment, you can use the Pagely Sync tool like this:
pagely sync ~/sites/example.com ~/sites/staging.example.com
- In case you have references to your production domain still inside your staging database, you can run a search and replace using WP-CLI. Jump over to your staging site’s location on the server by running the following:
cd ~/sites/staging.example.com
- Check the value of the cloned siteurl option for use with search-replace in next step:
wp option get siteurl
- Next, run a search and replace with WP-CLI using the following command:
wp search-replace --all-tables 'http://example.com' 'http://staging.example.com'
- While we’re here, let’s go ahead and flush the cache too:
wp cache flush
If everything ran successfully, a copy of your files and database should now exist within the staging environment. From here, you can perform changes to your new staging site without impacting your production site.
Next Steps
Depending on your site, you might also need to make additional changes to your staging site after cloning it. Every site is going to be different, but here's a few things to look for:
- Automated payments such as subscription renewals, invoicing, etc.
- Automated emails.
- Anything else that you would only want to run live in a production environment.
If you want to configure a more robust cloning system by creating a custom profile, take a look at the more advanced Pagely Clone Tool.