Drupal

Drupal is a free, web-based Open Source Content Management System (CMS) and Framework written in PHP and distributed under the GPL 2.0 (or later) licence.

According to W3Techs (2011-07-15), at least 2.3% of all websites worldwide are running with Drupal.

Drupal 8 is based on Symfony, a popular high performance PHP framework for web development.

Drupal was released for the first time in 2000 by Dries Buytaert. Since then it has been continuously developed and it is actively maintained by various contributors.


Note

This guide is about installing Drupal 8 via Drupal Composer Template.

You should be familiar with the basic concepts of

Prerequisites

PHP 7.2

We are using PHP in the stable version 7.2:

[isabell@stardust ~]$ uberspace tools version use php 7.2
Selected PHP version 7.2
The new configuration is adapted immediately. Patch updates will be applied automatically.
[isabell@stardust ~]$ uberspace tools version show php
Using 'PHP' version: '7.2'
[isabell@stardust ~]$

Database credentials

You’ll need your MySQL credentials. Get them with my_print_defaults:

[isabell@stardust ~]$ my_print_defaults client
--default-character-set=utf8mb4
--user=isabell
--password=MySuperSecretPassword
[isabell@stardust ~]$

Domain

Your website domain needs to be set up:

[isabell@stardust ~]$ uberspace web domain list
isabell.example
isabell.uber.space
[isabell@stardust ~]$

Database

Create an additional database, for example: isabell_drupal.

Composer

Note

The given Composer command uses the Drupal Composer Template and installs the latest stable release.

You might replace target parameter drupal with something more suitable.

cd into the directory above your document root /var/www/virtual/$USER/ to run to composer command:

[isabell@stardust ~]$ cd /var/www/virtual/$USER/
[isabell@stardust isabell]$ composer create-project drupal-composer/drupal-project:8.x-dev drupal --no-interaction
  - Installing drupal-composer/drupal-project (8.x-dev bdaa8fd): Cloning bdaa8fd53b from cache
Created project in drupal
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
[...]
> DrupalProject\composer\ScriptHandler::createRequiredFiles
Created a sites/default/settings.php file with chmod 0666
Created a sites/default/files directory with chmod 0777
[isabell@stardust isabell]$

RewriteBase

Search for # RewriteBase / and remove the leading # to activate this statement.

[isabell@stardust isabell]$ vi drupal/web/.htaccess
RewriteBase /

SCM

It is a very good time to initialise a repository witin the drupal directory. This step is optional but highly recommended ;-D

drush-launcher

In order to make use of Drupal Composer Template’s drush, you will need to install the drush-launcher:

[isabell@stardust isabell]$ wget -O ~/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar
[isabell@stardust isabell]$ chmod +x ~/bin/drush

Installation

There are at least two different ways to install Drupal:

Interactive Installer

Open a browser and visit the URL of your domain. It is self-explanatory, for specific steps and screenshots checkout Running the Interactive Installer.

drush site:install

Do it via Drush at the command line, see drush site:install for details.

Configuration

Trusted Host setting

For Drupals protection against HTTP HOST Header attacks, you need to configure Trusted host security setting in settings.php, which was introduced in Drupal 8.

[isabell@stardust isabell]$ vi html/sites/default/settings.php

Insert this configuration for the domains given above:

$settings['trusted_host_patterns'] = [
  '^isabell\.example$',
  '^isabell\.uber\.space$',
];

Cronjob

For executing periodical tasks like e.g. updatíng the search index, purging old logs or checking for updates, you will need to create a cronjob.

Get your cron url for your site at Administration > Configuration > System > Cron (/admin/config/system/cron). We create a cronjob with above url which runs once a day:

[isabell@stardust isabell]$ crontab -e
4 0 * * * wget -O - -q -t 1 https://isabell.example/cron/CsUKMfKtaFI8P3CaFpWy6iMIJPjjAwnm-Svs6wXb_LSrxqLnlbv85qy5us0YSnK3iQpthKoIrQ

Updates

Note

For Drupal core and contrib updates, configure Reports > Available updates > Settings (/admin/reports/updates/settings) within your site and subscribe Security advisories and public service announcements too!

Core Updates

In case of Core updates see the Updating Drupal Core section of Drupal Composer Template.

Contrib Updates

Updates of contributed modules work like this, e.g. for the geofield contrib:

[isabell@stardust drupal]$ composer update drupal/geofield --with-dependencies

Tested with Drupal 8.7.9 and Uberspace 7.3.7.0

Written by: Florian Latzel <https://netzaffe.de>