How to Host Drupal Sites using SiteGround

This page contains affiliate links, meaning we get a commission if you decide to make a purchase through our links, at no cost to you. Please read our disclosure for more info.

Don’t forget to subscribe to our YouTube channel to stay up-to-date.

SiteGround is a popular hosting provider for Drupal, WordPress or any PHP powered website.

They offer a wide variety of hosting packages, from shared, managed, and cloud hosting.

SiteGround Hosting Packages.

However, in this video we focus on their shared hosting product.

They offer three plans; StartUp, GrowBig and GoGeek. The StartUp plan only allows for a single website so we recommend that you go for the GrowBig or GoGeek as they offer more functionality and allow you to host unlimited websites.

All plans offer free SSL (using Let’s Encrypt) and “Out-of-the-box Caching”, where they use NGINX to cache static assets such as images and files. They also offer Memcached, which can help with speeding up your Drupal site.

The GoGeek plan allows you to host and deploy your Drupal site using Git, which could be helpful if you use Git to manage your Drupal site.

In this video, you’ll learn how to install Drupal using the GoGeek plan on SiteGround.

You’ll also learn how to:

  • SSH into the server.
  • Change PHP version.
  • Download and install Drupal using Composer.
  • Set up private files directory.
  • Set up configuration export.
  • Configure Memcache to speed up Drupal.
  • Install SSL.
  • Install Drupal using SiteGround’s app install and deploy using Git.

Set up SiteGround Hosting

1. To purchase a hosting package, go to SiteGround’s plans page and click on GET PLAN on the GoGeek.

SiteGround Hosting Plans.

2. Enter in a domain name for the hosting. You can use one which you’re already registered or you can register a new one.

Then click Proceed.

3. Enter in account, client and payment information. Then scroll down to “Purchase Information” where you can change the plan, data center and billing period.

Then click on “Pay now”.

Create Drupal Site on SiteGround

1. Log into SiteGround and click on “Website” in the toolbar.

2. Then click on “Create website”.

3. Choose what domain name you want to use. If you wish to register a new one, click “New Domain”. If you already have an existing domain then click on “Existing Domain”.

You can use a temporary SiteGround domain name (*.sg-host.com) which can be changed later to a proper domain name.

Click on Select under “Temporary Domain”.

4. From “Set Up Site” scroll down and click on “Skip & Create Empty Site”.

5. You should see the message “Creating Your Site…”. It’ll take about 2 minutes for your website to be built.

6. Once created you can access your site by clicking on “GO TO SITE” or you can manage your site by clicking on “SITE TOOLS”.

SiteGround Hosting Interface

Dashboard

You can see site information such as disk space used, IP and name servers.

Site

From Site, you can create, edit and upload files and directories into your SiteGround website using the “File Manager”. FTP accounts and database can be created as well.

Security

From Security, you can manage your backups, SSL certificates, enforce HTTPS and more.

Speed

From Speed, you can configure Nginx, dynamic cache and Memcached.

Domain

From Domain, you can manage your domain name, subdomains, redirects and DNS settings.

Email

From Email, you can manage email accounts, forwarders, autoresponders and more.

Statistics

From Statistics, you can see how much traffic your site is getting, as well as error and access logs.

Devs

From Devs, you can set Git, cron jobs, change PHP settings, manage SSH keys and install applications.

Configure SSH Access

We’ll need to set up SSH hosting access to install Drupal using the terminal.

1. Go to Devs, “SSh Keys Manager”. You can generate a new key by clicking on GENERATE. If you want to use an existing key then click on IMPORT.

2. Copy in a key and click on IMPORT.

SSH into Server

Once an SSH key has been created, you’ll be able to use the SSH credentials on the “SSH Keys Managers” page.

On up the terminal and SSH using the command below. Replace the port, hostname and username accordingly.

ssh -p port username@hostname

Change PHP Version

Let’s change the PHP version to PHP 8.0. The default version, as of this recording, is PHP 7.4.

1. Go to Devs, “PHP Manager” and click on the pencil icon.

2. From “Set PHP Version”, select “Change PHP version manually”, then select “PHP 8.1.14”.

NOTE: Adjust PHP version accordingly. If there’s a new stable PHP version then select a different version.

PHP on Command Line

Even though we changed PHP to a newer version the command line version will still be an older one.

If you type:

php -v

You will see that it’s a different version.

But if you go to /usr/local/bin, you can see other versions of PHP.

If you want to run PHP 8.2, then just run php82 instead of php on the command line.

Download Drupal using Composer

Go back into your home directory, then go to www and then the site folder.

Run the following command:

cd ~/www/ivanz15.sg-host.com
php81 /usr/local/bin/composer.phar create-project drupal/recommended-project drupal

Create Symlink for Docroot

When you download Drupal using Composer it’ll add it into a drupal directory.

But we need to make the web directory within drupal the docroot. To achieve this we’ll use a symlink.

First, we’ll need to delete the current public_html folder.

cd ~/www/ivanz15.sg-host.com
rm -r public_html/

Then create the symlink, within the same directory.

ln -s drupal/web ./public_html

Once created you should see the link.

Download Drush

Go into the Drupal directory and download Drush.

cd drupal
php81 /usr/local/bin/composer.phar require drush/drush

Setup Database

Before we can install Drupal we need to create a database.

1. In SiteGround, click on MySQL under Site and click on CREATE DATABASE.

2. Once the database is created click on CREATE USER to create a database user account.

3. You’ll need to change the password for the database user. From users, click on the options icon on the account. Click on “Change Password”.

Access phpMyAdmin

You can manage the database using phpMyAdmin. Click on PHPMYADMIN within MySQL and click on ACCESS PHPMYADMIN.

Install Drupal

1. Go to the actual website and you should see the installation page. First, select a language.

2. Select Standard as the installation profile.

3. Enter in the database credentials such as name, username and password.

4. Fill in the form on the final step and click on “Save and continue”.

Configure Private Files

To configure the private files directory, you’ll need to add a settings value into the settings.php file.

You can edit the settings.php file in two ways. First, you can do in via the command line, or you can modify it through SiteGround. Let’s do it using SiteGround.

Create Private Folder

First we need to create the private folder. You can do it via the command line or using the SiteGround file manager.

cd ~/www/ivanz15.sg-host.com/drupal
mkdir private

Update File Private Path Settings

1. In SiteGround, click on Site, “File Manager” and navigate to the settings.php file (drupal/web/default/settings.php).

2. You’ll need to change the permission on the file to edit it. Right click on the file and click on “Change Permissions”.

Change the permission to 744 to edit the file.

3. Add the following before into settings.php.

$settings['file_private_path'] = $app_root . '/../private';

Once you’ve added the file private path settings make sure you change the permission on settings.php back to 444.

Can’t Change Permission

If you try and change the permission back to 444 via SiteGround you may get the following error.

This happens because settings.php hasn’t been selected correctly if you navigate the folders and right click straightaway on the file. Make sure you first left click on the file, which selects it, then right click and select “Change Permissions”.

Change Permissions via Command Line

You can change the permission on the file via the command line.

cd ~/www/ivanz15.sg-host.com/drupal/web/sites/default
chmod 444 settings.php

Config Sync Directory Settings

1. Open settings.php and add the following:

$settings['config_sync_directory'] = $app_root . '/../config-export';

2. Create a config-export directory through the command line.

cd ~/www/ivanz15.sg-host.com/drupal
mkdir config-export

3. To import and export configuration, run the following:

// Config import
php81 ./vendor/bin/drush cim
// Config export
php81 ./vendor/bin/drush cex

NOTE: You’ll need to install Drush for the commands to work.

Set up Memcache

Configure Memcache Module

1. Download the Memcache module for Drupal.

php81 /usr/local/bin/composer.phar require drupal/memcache

2. Once downloaded, go and install the module via Extend.

3. Open up settings.php again and copy some code from the SiteGround documentation.

$settings['memcache']['servers'] = ['127.0.0.1:11211' => 'default'];
$settings['memcache']['bins'] = ['default' => 'default'];
$settings['memcache']['key_prefix'] = '';
$settings['cache']['default'] = 'cache.backend.memcache';

Turn on Memcached on SiteGround

Go to Speed, Caching and switch it on using the toggle.

Install Memcache Admin Module

Go to Extend and install the Memcache Admin sub-module that comes with Memcache.

Go to Configuration, “Memcache Admin Settings” and check “Show memcache statistics at the bottom of each page”.

Then you’ll see statistics at the bottom of each page.

Add Custom Domain and Point A Record

1. Go to Websites in SiteGround and click on the options link then “Change Primary Domain”.

2. Enter in your new domain in “New Domain”.

3. Copy the IP from the site tools dashboard.

4. Go to where your domain is registered and create an A record for the sub-domain.

NOTE: Creating an A record is different depending on the domain registrar. Refer to their documentation.

You may get a site error when viewing the site on the new domain. You’ll need to flush the DNS cache on your computer to see the latest changes.

Install SSL

1. Go to Security, “SSL Manager” and select the domain and “Let’s Encrypt” from the drop-down.

2. Click on “HTTPS Enforce” and switch it on for the domain.

Install Drupal using SiteGround App Installer

1. Go ahead and create a new website on SiteGround.

2. From site tools, click on Dev, “App Installer” and select Drupal from Application.

3. Scroll down to Admin Info and enter in a username, password and email.

Then click on Install.

Set up Git

1. In SiteGround go to Dev, Git and make sure there’s an option from “Select Installation” and click on Create.

2. Click on Git Info to get the clone command.

NOTE: You’ll need to add your SSH key to clone a git repository. We covered that earlier in the video.

3. Open up your terminal and paste in the git clone command.

Configure .gitignore File

SiteGround create a .gitignore file but only adds “tmp/*”. We’ll need to add a few more items with the ignore file.

Open example.gitignore, copy it into .gitignore and add “/core”.

/vendor/
/core
sites/*/settings*.php
sites/*/services*.yml
sites/*/files
sites/*/private
sites/simpletest
tmp/*

Remove Ignored Files from Git

When SiteGround created a git repository, it added all the files and folders in the repo. Now that we are ignoring folders and files we need to remove them from the repository.

Go to this Stack Overflow answer and run the following command:

git rm -r --cached .
git add .
git commit -m "Drop files from .gitignore"

Run Composer Install

Once you’ve removed all the ignored files from git, your website will break because libraries from the vender directory were deleted.

You’ll need to SSH into the server and run composer install to download them again.

Summary

If you’re looking for good shared hosting with lots of features such as SSL, Memcache, Git and more then SiteGround is the hosting provider for you.

Drupal can be installed manually via Composer, or you can use their application installer.

However, we recommend that you choose their GrowBig or GoGeek plans.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.