Skip to main content
How to Create a Staging Environment

A comprehensive guide on how you can create a staging environment from your Cloudways Platform dashboard.

Usama Zafar avatar
Written by Usama Zafar
Updated over 4 months ago

Table of Contents

Your website is critical to you and your customers; therefore, making 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 blind whenever 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 significant differences.

  1. The staging website is accessible publically using the link; however, you can make it private by creating it password-protected (.htpasswd).

  2. Search engines can’t index your staging website.

  3. Changes you make on your staging website will only affect your live website if you push the changes (explained in the Staging Management and Operations below).

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.

How to Create a Staging Environment

You can set up a staging environment in a few minutes. Here is a step-by-step procedure for setting up a staging environment for your application.

First of all, please select your platform:

Cloudways Flexible

Step #1 — Navigate to Your Application

Log in to your Cloudways Platform using your credentials.

  1. From the top menu bar, open Servers.

  2. Then, you need to 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

  1. Hover over the grid menu to view more options.

  2. Next, click Clone App/Create Staging.

Classic Interface

New Interface

  1. Under Application Management, click Staging Management.

  2. Next, click Launch Staging Application.

  3. Here, a dialog box will appear, prompting some information.

    Important

    Please note that if you are creating a staging application on a different server available in your Cloudways account, it must meet the minimum application requirements.

  4. You can choose the same server or a different server to build the staging environment.

  5. Tick Create as Staging.

  6. Finally, hit Continue.

    Classic Interface

    New Interface

    In the case of New Interface, click 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. The time will depend on the amount of data your web application contains. You will see a notification once the staging application is ready.

If you see any warning highlighting the differences between packages on source and destination servers, you may follow this guide to upgrade or install your server packages. We recommend checking and upgrading packages before to avoid any compatibility issues and then creating a staging application.

Classic Interface

New Interface

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. You can click here to learn more about updating the session path.

Once the staging application is launched, it will also be available in the applications list with the staging tag.

Classic Interface

New Interface

Cloudways Autonomous

When you create a staging application in Cloudways Autonomous, it is not counted as a separate application; however, number of visits, disk usage, and bandwidth consumption are counted in your plan quota.

Important Notes:

  • One application can only have one staging environment associated with it.

  • The staging application is only for testing purposes; thus, it is not scalable and must not be used for any production environment.

Step #1 — Navigate to Your Application

Log in to your Cloudways Platform using your credentials.

  1. From the side menu bar, open Applications.

  2. Then, you need to choose your desired application.

  3. Next, click Workflow/Tools.

  4. Select Staging Management.

Step #2 — Creating a Staging Environment

Finally, click Launch Staging Application.

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. The time will depend on the amount of data your web application contains. You will see a notification once the staging application is ready.

Staging Management and Operations

To help you get started with the basics of managing a staging environment, let’s first learn about accessing it.

First of all, please select your platform:

Cloudways Flexible

How to Access Staging Environment

  1. To access the staging environment, navigate to Servers from the top menu bar.

  2. 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 you need it, but we recommend keeping it protected because of security reasons.

Important

Your admin login credentials will be the same for your live and staging sites 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.

  1. Navigate to the Staging Management from the side menu.

  2. Click Push.

    Classic Interface

    New Interface

    Next, a dialog box will appear asking for your preferences.

  3. Web Application Files: Select this option to apply the changes to the web application files made in the staging environment to the live environment. Here, "web application files" refer to the files in the public_html directory.

    1. 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.

    2. Incremental: Select this option if you want to apply the web application file 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.

    1. 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.

    2. 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 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 built-in “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, 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.

  • If 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.

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 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.

  1. Navigate to the Staging Management from the side menu.

  2. 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 file changes of the live environment on the staging environment. Here, web application files refer to the files in the public_html directory.

    1. 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.

    2. Incremental: Select this option if you want to apply the web application file 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.

    1. 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 current values.

    2. 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 explicitly created for development and testing purposes. They are not designed to be used as live production websites.

Cloudways Autonomous

How to Access Staging Environment

  1. To access the staging environment, navigate to Applications from the left menu bar.

  2. Then, you need to choose your desired application.

  3. Under Overview, you will find your staging application tagged as Staging. Next, click Manage Environment.

  4. Now, you are under the staging management area. Here, you will find your Application URL under your application name.

  5. Navigate to the Overview tab to find your Access Details. By clicking SSH/SFTP Details, you can view your host, username, and password to connect to your application remotely via SSH/SFTP. Lastly, by clicking Database Access, you can view your database name, hostname, username, and password.

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 you need it, but we recommend keeping it protected because of security reasons.

Important

Your admin login credentials will be the same for your live and staging sites unless you change them.

To view the admin credentials, head to Manage Access > Password Protection. If you wish to disable this password protection, you may toggle it off.

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.

  1. Navigate to the Staging Management from the side menu.

  2. Click Push.

    Next, a dialog box will appear asking for your preferences.

  3. Web Application Files: Select this option to apply the changes to the web application files made in the staging environment to the live environment. Here, the web application files refer to the files in the public_html directory.

    By selecting this option, you will 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.

  4. Database: Select this option if you want to implement the database changes of the staging environment on the live environment.

    1. 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 current values.

    2. Selected Tables: Select this option if you want to overwrite specific database tables of the live application with the staging application's database tables.

    Tip

    By clicking What Will Happen, you can visualize the changes that will take place if you confirm the selection.

  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 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.

Important Notes

  • It is advised that you initiate the push request with some extra care, and it should be started 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 built-in “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, manually add those for the staging site and 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.

  • If your live site does not show recent changes, clear your browser’s cache and purge your WAF services cache, e.g., Cloudflare.

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 is handy if your staging environment is broken or outdated, as it helps you pull all the latest data from the live site to a staging environment. Here is how you can perform the pull operation; we use a WordPress site for demonstration.

  1. Navigate to the Staging Management from the side menu.

  2. Click Pull.

    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 file changes of the live environment on the staging environment. Here, web application files refer to the files in the public_html directory.

    By selecting this option, you will 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.

  4. Database: Select this option if you want to implement the database changes of the live environment on the staging environment.

    1. Full DB: Select this option to completely overwrite your staging application’s database with the live application's database, including all the database objects, functions, tables, and current values.

    2. Selected Tables: Select this option if you want to overwrite specific database tables of the staging application with the live application's database tables.

    Tip

    By clicking What Will Happen, you can visualize the changes that will take place if you confirm the selection.

  5. Finally, click Proceed. The time required to complete this operation depends on the size of your application.

You have learned to set up a staging environment and how to manage it. The staging environment is explicitly created 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?

In Cloudways Flexible, 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.

In Cloudways Autonomous, all applications are protected by Cloudflare Enterprise by default.

Do I have to pay additionally for a staging environment?

In Cloudways Flexible, 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.

In Cloudways Autonomous, pricing will be counted as per plan usage (Bandwidth, Visits, and Disk Usage).

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, and what happens if I delete the live application?

Deleting a staging application is a straightforward process, identical to deleting a regular application. However, the implications of deleting a live application depend on the Cloudways service you're using.

  • For Cloudways Flexible: When you delete the live application, any linked staging application(s) are not automatically removed. To ensure a clean removal, it is necessary to delete these staging applications manually.

  • For Cloudways Autonomous: In the case of Cloudways Autonomous, if you delete the live application, the associated linked staging application will be automatically deleted.

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.

Did this answer your question?