If you are a developer of any level you must know about Git for source code management. Git is very popular when it comes to interacting with multiple team members and open source contributors for building coding solutions. I’ve written a short series on Git for beginners covering, commands cheat sheets, Branches, Conflicts etc.
The best thing about GIT is it allows to create custom workflows manually or by integrating 3rd party tools for automatic deployment and Continuous Integration in PHP.
The Cloudways PHP Hosting platform allows you to deploy PHP application from your git repositories. Your git repository must support git over SSH for this to work. For git deployment, you need to follow simple steps given below.
Step 1: Signup & Launch Server
Firstly, Signup at Cloudways platform, Launch your first Server and application which you need. Next, Move to the Application by selecting any app from application page.
Step 2: Generating SSH Keys
In this Step you need to download SSH keys by moving to Deployment via Git tab,
We will use these keys to allow access from your Cloudways server to your git repository. Now click on the Generate SSH Keys button to generate the keys.
Now, click on View SSH Keys to download the SSH Public Key that we will use in the next step.
Step 3: Upload SSH Key To GitHub Repository
On Github move to the repository which code you need to deployed. If you are using another git service, you will have to find the equivalent way of completing them. Go to Settings -> Deploy keys and Click on the Add Deploy Key button to add the SSH key we downloaded. You can give a name to this key too in the title field and copy the key to the box. Click on the Add Key button to save the SSH key.
Step 4: Copy the SSH Address Of Repository
Copy the repository address as shown in the image below. Make sure to copy the SSH address as other formats (like HTTPS) are not supported.
Step 5: Deploy PHP Application Code from Your Repository
- Back on Cloudways console, paste the SSH address you got in Step 4 into the Git Remote Address” field.
- Then choose the branch of your repository you want to deploy from. In this example, we use the master ” branch.
- Next, type the deployment path (i.e. the folder in your server where the code will be deployed). Make sure to end it with a /. If you leave this field empty, the code will be deployed to public_html/.
- Finally, click on the Start Deployment button to deploy your code to the selected path.
Step 6: Repository Successfully Cloned
You will get a notification once the PHP application deployment process has been completed.
You have further options to delete the repository from the server (no files will be deleted, see FAQ below), pull the latest changes or change the branch you deploy from.
Automatic Deployment Tools Integration
Cloudways also supports Github automatic deployment tools. You can easily integrate them to deploy PHP application by just using the master credentials provided on your server page. The guides are also available for automatic deployment with Deploybot, Deployhq and Envoyer. You can easily follow the steps and setup the deployment with zero downtime on cloudways. Remember you need your server SSH key in most of the cases you can get from Deployment with git tab as shown in step 2.
Shahroze is a PHP Community Manager at Cloudways - A Managed PHP Hosting Platform. He’s always in search of new frameworks and methods to implement them. Besides his coding life, he loves movies and playing soccer with friends. You can email him at firstname.lastname@example.org
Create PHP websites without the worry of server management.
Deploy your PHP app on optimized PHP hosting servers.