This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

CloudwaysCDN — a powerful solution that offers superior performance and satisfied global audience for your business. Read More

How to Clone a Drupal Site From Git to Cloudways

Updated on  23rd January

4 Min Read
Reading Time: 4 minutes

Git has become the standard of collaborative code development. Using the built-in version management tools and the unique deployment system that comprises of pulling the latest version of the code to any deployment platform, developers could make sure that the project deadlines are achieved by the distributed team.

drupal-git-to-cloudways

In this tutorial, I am going to walk you through the steps needed to pull the code of a Drupal website from the Git and deploy it on the Cloudways servers.

  1. Launch Drupal 8 on Cloudways
  2. Prepare the Server for the Drupal Website
  3. Remove all Files and Folders in the Application
  4. Delete the existing Database
  5. Start the Cloning Process
  6. Installing the Required Dependencies
  7. Import Data from the existing Website
  8. Create a new settings.php file
  9. Change Permissions
  10. Installation of the new website

Pre-Requisites

  • You will need a software like PuTTy to connect to CW server
  • A Cloudways account with Drupal 8 installed on Server
  • A Git account

Launch Drupal 8 on Cloudways

You will need to launch a Drupal 8 application on your Cloudways server. This allows you to take full advantage of the caching and server configuration that Cloudways specifically offers for Drupal websites.

Prepare the Server for the Drupal Website

Next, you need to connect to the website you have already launched by using a CLI software of your choice (I recommend using PuTTY)

putty-server-connect

Remove All Files and Folders in the Application

Before you clone your existing site to your Drupal server on Cloudways, you will need to remove all files and folders already present in the application’s public_html folder through the following command

cd applications/<application name>/public_html

Since the application name is similar to the database name, you could use the following command to remove all the files in it:

Delete the Existing Database

cloudways-database-manager

In addition to removing all files and folders, you also need to remove the existing database. Launch the database manager in your Cloudways application and select information_schema from the dropdown list. Then, use the following command to delete the database:

drop database <database_name>

Now, create a new database with the same name as the one you deleted by using the following command:

create database <database_name>

Note: The name has to be the same or the app won’t read the database.

Start the Cloning Process

Next, use the following command to clone your Git repository from Git

Example: git clone https://github.com/username/name.git

Installing the Required Dependencies

Run the following command to install the required dependencies for Drupal 8.

Import Database From the Existing Website

Next, go to the Cloudways database manager and import your existing website’s database.

import-database

Once the import process finishes, truncate all the cache tables in the database. Use the commands in the following screenshot.

database-truncate

Create a New settings.php

Now, navigate to your Drupal’s sites/default folder using the cd directory_name command. Using the rm file_name command, delete the settings.php file if it is present in the directory.

Next, create a new settings.php file using the following command

Change Permissions

An important step at this point is to change the file permissions of the .htaccess file to 604. You will find this file in the sites/default/files/ directory. Navigate to this directory and change the permissions using the following command:

Installation of the Website

The preparations are now over and it is time to launch the application using the staging URL provided in the Application Access Detail tab.

launch-application

Once the URL has been launched, the Drupal Installation page would come up. Just follow the prompts of the wizard and the process finishes in several minutes.

drupal-installation-page

During the installation process, the wizard will ask you for the database. When prompted, enter your Cloudways application database credentials.

cloudways-database

Once it has finished, the setup will indicate that the website is already installed. Just click view the button and the website will be launched.

existing-site

You will now see the installed Drupal website.

drupal-site

Conclusion

Cloning your Drupal site from Git is a pretty straight-forward procedure. If you face an issue in the process or would like to contribute to the discussion, do leave a comment below.

If you are looking to improve your Drupal website’s performance,  do read this blog post by us on, How To Improve Drupal’s Performance Through Cloudways.

Share your opinion in the comment section. COMMENT NOW

Hamza Zia

Hamza is a Drupal Community Manager at Cloudways - A Managed Drupal Hosting Platform. He loves to write about Drupal and related topics. During his free time, he can be seen obsessing over Football, Cars, Android and Gaming.

Start Growing with Cloudways Today.

Our Clients Love us because we never compromise on these

Get Our Newsletter
Be the first to get the latest updates and tutorials.

THERE’S MORE TO READ.