Developers always try to create efficient workflows when it comes to deployment of code. They develop programs, integrate different automatic deployment tools and custom scripts to achieve the desired results. Currently, the most popular platform to host code files and manage them is Github. It provides fast and secure deployment features to live servers by creating webhooks. These webhooks validate the responses using API keys and secrets, and test the code with any integration tool using PHPUnit. If no serious errors are found in the code, then it is smoothly deployed to the live servers.
On the other hand, Cloudways creates these workflows to make their deployment job easier for the developers. Going along the way, Cloudways has introduced a Staging Environment Feature, through which you can PUSH and PULL your code to live server from staging. The feature doesn’t use GIT, but works on ftp system and updates the files using the Rsync utility.
What Is rsync & How It Works
If you know about Linux or have worked on file transferring apps, then you must know about Rsync utility. Using Rsync, you can efficiently transfer and synchronize files across the servers and computer systems. Rsync works on checksum verification and compares the names and filestamps. Seth Godin has a nice article on rsync that defines its working as follows:
“For a typical transfer, rsync compares filenames and file timestamps on the source and destination directory trees to assess which files should be transferred. However, if there’s any question of whether one or more files are in fact different but might share identical filenames and identical timestamps, rsync can be run in such a way so as to compare all the checksums on both the source and destination directories and then transfer only the items whose checksums differ.”
Well, Godin has explained the working process of Rsync in simple words. Now let’s see the workflow created by Cloudways to accomplish the staging and production server synchronization.
Create Staging Application On Cloudways
First of all, you must create an account on Cloudways PHP web hosting, and launch your server with a PHP application. Now navigate to Access Details Page of the app, and hover over the button at the bottom right corner of the screen. There you will see the option Clone app/Create staging, just click on it and it will create your staging application. During this process, you will have two options. You can create staging server on the same existing server you have, or you can also create a fresh new server for it. You can follow the gif below to better understand the process.
The process will complete after a few minutes. You will see a staging tag on the new application. Now open your staging application to access the details. Do note that staging applications do not clone DNS and SSL settings.
Staging Environment Management
You have successfully launched your first staging application. You can now see the Staging Management tab on both staging and live application like this:
The first one is live server and the next one is staging server. The staging management window provides you the option to PUSH and PULL the code to and from the live server. Meanwhile, on the live server you can select the staging app from which you want to pull the code. The process is quite simple. You just have to update changes on the staging application and then click the push button and the changes will reflect in the live server. You can carry out the following two procedures on both of the servers:
- Copy Data From Staging To Live
- Copy Data From Live To Staging
What Exactly You Can Push / Pull?
Whenever you try to push / pull the updated changes, the following two options are shown on the popup for transferring:
- Web Application Files
- Database
You can choose between the two options. If you don’t update database then there is no need to check the database option. Similarly you can do this with the web application files also. Check the web files option if you have any updated changes in files.
Change Logging
Everytime you Push/Pull the code, there is a log entry created in log files. You can see these logs from the similar window by clicking on View Logs button. The logs will show you the following options:
- Initiated App
- Date/Time
- Action
- Source App
- Destination App
Here is how it looks:
Backup Your Previous Files
The main concern for most of the developers is to create backups of the project. If any wrong changes occur in the application accidently, the developer can revert those changes and can save the project on live/staging server. Hence, in the staging environment of Cloudways, you can create backups of the existing files while pushing/pulling them from staging to live server.
Deploy Password Protection
Making your application secure from the external attacks is also quite a cumbersome job for the developers. Therefore Cloudways has integrated password protection feature in its staging environment. With it, you can deploy passwords on your staging applications. Just go to the Access Details tab and set up your username and password from there. After setting up both, toggle to the Enable option to let password protection deployed on your staging application.
Final Words
You have multiple options to deploy staging applications on live servers using Git and it’s supportive code hosting sites like GitHub, GitLab, Bitbucket etc. You can also create automated workflows by using Continuous integration tools and third party deployment tools. When it comes to backing up your files, Cloudways staging environment is the best option for developers. It allows them to easily clone their applications and increase its redundancy. In case of any accidental failures or unwanted actions, the data of the site reverts back from the staging application. While the added feature of deploying Password protection too adds an enhanced security layer to the staging applications.
Cloudways facilitates you to work with your code on staging/production servers. You can utilize this staging environment feature on any Cloudways server, as it gives you a complete compliance to build a fully redundant application. Still, if you have any further questions or suggestions about this article, you can share your comments in the comments section below.
Congratulations @shahroznawaz! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit