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.

📣 Try the fastest hosting platform with pay-as-you-go pricing & 24/7 expert support! MIGRATE NOW →

How to Clone a Drupal Site From Git to Cloudways

Updated on August 16, 2019

4 Min Read

Git has become the standard of collaborative code development. Using the built-in version management tools and the unique deployment system that comprises 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.

The clone module permits clients to form a duplicate of an existing item of site content (a hub) and then edit that copy. The creation is set to the current user, the menu and URL aliases are reset, and the words “Clone of” are embedded into the title to remind you merely are not altering the first content.

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:

rm -Rf *.*

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.

Stop Wasting Time on Servers

Cloudways handle server management for you so you can focus on creating great apps and keeping your clients happy.

Start the Cloning Process

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

git clone <your URL>

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.

cd name

composer install

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

touch settings.php

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:

chmod 604 .htaccess

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

Share This Article

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.

×

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

Thankyou for Subscribing Us!

×

Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Want to Experience the Cloudways Platform in Its Full Glory?

Take a FREE guided tour of Cloudways and see for yourself how easily you can manage your server & apps on the leading cloud-hosting platform.

Start my tour

CYBER WEEK SAVINGS

  • 0

    Days

  • 0

    Hours

  • 0

    Mints

  • 0

    Sec

GET OFFER

For 4 Months &
40 Free Migrations

For 4 Months &
40 Free Migrations

Upgrade Now