Table of Contents
Your website is critical to you and your customers; therefore, making any changes to your live website without testing it is almost the same as playing with the fire. The worst thing you can expect is your production website running into errors and then plenty of hours and effort to get it up and running. You’re going in blind every time you develop your website, or install any new update, theme, or plugin without a staging environment.
You can avoid all these troubles if you use a staging environment. A staging website is a replica of your existing website with three major differences.
The staging website is private; thus, not available to the public and may be password protected (.htpasswd).
Search engines can’t index your staging website if you keep it password protected.
Changes you make on your staging website will not affect your live website (until you push the changes).
Many hosting providers charge extra for a staging environment. However, Cloudways offers a free 1-click staging environment for all your applications and on all plans. This lets you accelerate your development workflow and save time and money in the long run.
Important
If you use a custom session path and encounter errors while cloning your application or creating a staging application. In that case, we recommend updating the session path to /home/hostname/application_name/public_html/var/sessions, as this directory "var/sessions" is excluded by default from cloning and staging creation processes to avoid any conflicts. Click here to learn more about updating the session path.
How to Create a Staging Environment
Setting up a staging environment is straightforward and can be set up in a few minutes. Here is a step-by-step procedure for setting up a staging environment for your application.
Step #1 — Navigate to Your Application
Log in to your Cloudways Platform using your credentials.
From the top menu bar, open Servers.
Then, choose the server where your desired application is deployed.
Classic Interface
New Interface
3. Next, click www.
4. Choose your application.
Classic Interface
New Interface
Step #2 — Creating a Staging Environment
Hover over the grid menu to view more options.
Next, click Clone App/Create Staging.
Classic Interface
New Interface
Under Application Management, click Staging Management.
Next, click Launch Staging Application.
Here, a dialog box will appear, prompting some information.
3. Choose the server where you would like to build the staging environment. You can choose the same server or a different server.
4. Tick Create as Staging.
5. Finally, hit Continue.
Classic Interface
New Interface
3. Choose the server where you would like to build the staging environment. You can choose the same server or a different server.
4. Finally, hit Continue.
You’re all set now, and the staging site deployment should begin shortly. The staging application will be a complete clone of your live application.
Once the staging application is launched, it will also be available in the applications list with the staging tag.
Classic Interface
New Interface
Staging Management and Operations
To help you get started with the basics of managing a staging environment, let’s first learn about accessing it.
How to Access Staging Environment
To access the staging environment, navigate to Servers from the top menu bar.
Then, choose the server where your staging application is deployed.
Classic Interface
New Interface
3. Next, click www.
4. Select your staging application.
Classic Interface
New Interface
Under Staging Management, navigate to Access Details to view your Staging Application URL, Username, Password, and Database credentials.
By default, your staging application is password protected (.htpasswd) for enhanced security; thus, you will be prompted for the username and password while accessing the staging application. You can also disable password protection if needed, but we recommend keeping it protected due to security reasons.
Important
Your admin login credentials will be the same for your live site and staging site unless you change them.
Classic Interface
New Interface
Under Application Management, navigate to Access Details to view your Staging Application URL, Username, and Password.
For Database credentials, visit Database.
Push Staging Site to Live
When you develop your website or make changes in the staging environment, the next steps are testing and implementing those changes in the production environment. This is where the 1-click Staging Push feature comes into play to push staging environment changes to the live site.
Navigate to the Staging Management from the side menu.
Click Push.
Classic Interface
New Interface
Next, a dialog box will appear asking for your preferences.
3. Web Application Files: Select this option if you want to apply the web application files changes of the staging environment on the live environment. Here, web application files refer to the files present in the public_html directory.
a. Overwrite: Select this option if you want to completely overwrite your live application’s web files with the staging application’s web files. Please note that this action will overwrite all files, such as your .htaccess file and other configuration files, etc.
b. Incremental: Select this option if you want to apply the web application files changes of the staging environment on the live environment incrementally, which means only the web application files changed in the staging environment will be pushed to the live environment. Files that are deleted in the staging application will not be deleted in the live application.
You can also exclude specific files and folders as well which you don't want to push but please note that you can only exclude up to nine directories.
4. Database: Select this option if you want to implement the database changes of the staging environment on the live environment.
a. Full DB: Select this option if you want to completely overwrite your live application’s database with the staging application's database, including all the database objects, functions, tables, and their current values.
b. Selected Tables: Select this option if you want to overwrite specific database tables of the live application with the staging application's database tables.
5. Backup: Select this option if you wish to take an on-demand backup of your live application before pushing the changes, and we recommend doing it to have a good restore point in case of some issues.
6. Finally, click Proceed. The time required to complete this operation depends on the size of your application.
Tip
If your live site manages user’s data or online orders, etc., in a particular table, then the selected tables option helps to exclude those tables while pushing the staging site to the live site.
Classic Interface
New Interface
Important Notes
It is advised to initiate the push request with some extra care, and it should be initiated in off-peak hours when your website encounters minimum traffic.
We always suggest you take an on-demand backup of your live application before pushing the changes, so you can always roll back if anything goes wrong.
The inbuilt “Search and Replace” feature will only look for your primary domain and replace it with your staging domain. If you have an additional domain mapped, you will need to manually add those for the staging site and then perform Search and Replace through the database manager.
After the push request, the staging site will still be available for further development without affecting the live site.
In case your live site does not show recent changes, then be sure to clear your browser’s cache and purge your WAF services cache, e.g., Cloudflare, to view the recent changes on your live site.
We do not offer any CDN options for staging applications.
Pull Live Site to Staging
The pull operation helps import live site data, e.g., web files and databases, onto your staging environment to create a replica. This comes in handy if your staging environment is broken or outdated, as it helps you to pull all the latest data from the live site to a staging environment. Here is how you can perform the pull operation; we are using a WordPress site for demonstration purposes.
Navigate to the Staging Management from the side menu.
Click Pull.
Classic Interface
New Interface
Here, a dialog box will appear to ask for your preferences.
3. Web Application Files: Select this option if you want to apply the web application files changes of the live environment on the staging environment. Here, web application files refer to the files present in the public_html directory.
a. Overwrite: Select this option if you want to completely overwrite your staging application’s web files with the live application’s web files. Please note that this action will overwrite all files, such as your .htaccess file and other configuration files, etc.
b. Incremental: Select this option if you want to apply the web application files changes of the live environment on the staging environment incrementally, which means only the web application files changed in the live environment will be pushed to the staging environment. Files that are deleted in the live application will not be deleted in the staging application. You can also exclude specific files and folders as well which you don't want to pull.
4. Database: Select this option if you want to implement the database changes of the live environment on the staging environment.
a. Full DB: Select this option if you want to completely overwrite your staging application’s database with the live application's database, including all the database objects, functions, tables, and their current values.
b. Selected Tables: Select this option if you want to overwrite specific database tables of the staging application with the live application's database tables.
5. Finally, click Proceed. The time required to complete this operation depends on the size of your application.
Classic Interface
New Interface
Deployment Logs
The Deployment Logs allow you to view the history of the Push and Pull requests easily. Simply click View Logs to see the history.
Classic Interface
New Interface
You have learned to set up a staging environment and how to manage it. The staging environment is created specifically for development and testing purposes. They are not designed to be used as live production websites.
That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.
FAQs
Can I see the logs of file changes?
Every Push and Pull request is individually recorded in the deployment logs, and you can have a detailed history of all requests.
Can I secure my staging site with any security?
All staging websites can be protected by SSL certificates, which encrypt all end-to-end communication. You can use a FREE Let’s Encrypt SSL certificate or use your Custom SSL certificate. Most importantly, your staging site is password protected (.htpasswd) by default for enhanced security.
Do I have to pay additionally for a staging environment?
The staging site incurs no additional charges if hosted on a server already present in your account. However, if you launch a new server, the regular server charges apply.
How many staging sites can I launch?
You can launch as many staging sites as you like, but be sure to check your server's disk space to avoid unnecessary burdens.
Do application settings also clone to the staging site?
No, the application settings are not cloned to your staging application.
When should I use staging, and when should I use cloning?
Both Staging and Clone features appear similar; the use cases and application scenarios for both features are very different.
Use Cloning if you need a copy of your live application on a new, existing, or the same server, and take that application live after applying modifications.
Use Staging if you need to create workflows focused on application development and testing. A staging application offers an isolated environment that allows you to push and pull changes between Live and staging applications without impacting the live environment.
How do I delete a staging application?
If you delete the live application, the linked staging application is not automatically removed. Instead, you have to delete those applications manually. Deleting a staging application is the same as deleting a regular application. First, visit the target application, hover over the grid, and select Delete App.
What is the impact of the staging application on server management features?
Cloning the Server: When you clone a server that hosts both the live and the staging applications, the staging applications (tagged with the staging label) on the source server will not be replicated on the cloned server.
Transfer Server: Transferring a server to a different Cloudways account follows the standard procedure, as mentioned in this KB article. However, the following conditions will apply when you are transferring a server with a staging application.
When both live, and staging applications are hosted on the same server, the new owner will have access to both applications.
When the server hosting the live application is transferred, the new owner will not have access to any staging applications located on a different server.
When a server hosting the staging application (but not the live application) is transferred, the new owner will not have access to the live application. The mapping between the live and the staging applications will be removed.
Can a team member access a staging application only?
Yes, you can allow team members to have access to the staging application only. However, having said that, if they are not granted access to your production site, they will not be able to push any changes to production.
Can I use my staging site as any other application?
Although this is not suggested or recommended, you can still use the staging site as any other application.