stepbystep:drupal

This is an old revision of the document!


Drupal 9

We need unzip.

# apt install unzip

Prepare folders and permissions (user = server manager; www-data = user nginx running as).

# sudo chown user /var/www/
# mkdir /var/www/.cache
# mkdir /var/www/html
# sudo chown -R user:www-data /var/www/.cache /var/www/html

Install Drupal 9 (currently 9.1.4 version) by composer (executed as user).

$ composer create-project drupal/recommended-project /var/www/html

Securing installation before continue to install by standard web interface.

$ cd /var/www/html/web
$ sudo chown -R user:www-data .
$ find . -type d -exec chmod u=rwx,g=rx,o= '{}' \;
$ find . -type f -exec chmod u=rw,g=r,o= '{}' \;
 
$ sudo chgrp -R www-data /var/www/html/vendor
$ sudo chgrp www-data /var/www/html
 
$ sudo chmod 770 sites/default
$ chmod -R 660 sites/default/*
$ mkdir sites/default/files
$ sudo chown -R user:www-data sites/default/files
$ cp -a sites/default/default.settings.php sites/default/settings.php
$ sudo chgrp www-data sites/default/settings.php

Browse to https://dbopen.ba.cnr.it to complete installation.

  • Language: English
  • Select an installation profile: Minimal Build a custom site without pre-configured functionality. Suitable for advanced users.
  • Database configuration (all defaults)
  • Configure site
    • Site name: DBOpen
    • Site email address: dbopen@ba.cnr.it
    • Email address: dbopen@ba.cnr.it
    • Check for updates automatically: YES
    • Receive email notifications: NO

Some more secure permissions.

$ sudo chmod 750 sites/default
$ sudo chmod 640 sites/default/*.php
$ sudo chmod 640 sites/default/*.yml

First useful UI settings:

  • BROWSE admin/appearance and install&set admin theme (Seven) and default theme (Bartik) and uninstall Stark
  • BROWSE admin/config/people/accounts and select the the “Only site administrators can create new user accounts” option

Install Drush

$ cd /var/www/html/
$ composer require drush/drush:^10
 
$ vendor/bin/drush --version
Drush Commandline Tool 10.4.0

Composer.json at this step:

{
    "name": "drupal/recommended-project",
    "description": "Project template for Drupal 9 projects with a relocated document root",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "homepage": "https://www.drupal.org/project/drupal",
    "support": {
        "docs": "https://www.drupal.org/docs/user_guide/en/index.html",
        "chat": "https://www.drupal.org/node/314178"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "composer/installers": "^1.9",
        "drupal/core-composer-scaffold": "^9.1",
        "drupal/core-project-message": "^9.1",
        "drupal/core-recommended": "^9.1",
        "drush/drush": "^10"
    },
    "conflict": {
        "drupal/drupal": "*"
    },
    "minimum-stability": "stable",
    "prefer-stable": true,
    "config": {
        "sort-packages": true
    },
    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "web/"
            }
        },
        "installer-paths": {
            "web/core": [
                "type:drupal-core"
            ],
            "web/libraries/{$name}": [
                "type:drupal-library"
            ],
            "web/modules/contrib/{$name}": [
                "type:drupal-module"
            ],
            "web/profiles/contrib/{$name}": [
                "type:drupal-profile"
            ],
            "web/themes/contrib/{$name}": [
                "type:drupal-theme"
            ],
            "drush/Commands/contrib/{$name}": [
                "type:drupal-drush"
            ],
            "web/modules/custom/{$name}": [
                "type:drupal-custom-module"
            ],
            "web/profiles/custom/{$name}": [
                "type:drupal-custom-profile"
            ],
            "web/themes/custom/{$name}": [
                "type:drupal-custom-theme"
            ]
        },
        "drupal-core-project-message": {
            "include-keys": [
                "homepage",
                "support"
            ],
            "post-create-project-cmd-message": [
                "<bg=blue;fg=white>                                                         </>",
                "<bg=blue;fg=white>  Congratulations, you’ve installed the Drupal codebase  </>",
                "<bg=blue;fg=white>  from the drupal/recommended-project template!          </>",
                "<bg=blue;fg=white>                                                         </>",
                "",
                "<bg=yellow;fg=black>Next steps</>:",
                "  * Install the site: https://www.drupal.org/docs/8/install",
                "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
                "  * Get support: https://www.drupal.org/support",
                "  * Get involved with the Drupal community:",
                "      https://www.drupal.org/getting-involved",
                "  * Remove the plugin that prints this message:",
                "      composer remove drupal/core-project-message"
            ]
        }
    }
}

Change composer.json to enable dev module version.

nano -w composer.json
  "minimum-stability": "dev"

Trust host pattern

$ nano -w web/sites/default/settings.php
  $settings['trusted_host_patterns'] = [
    '^dbopen\.ba\.cnr\.it$',
  ];

Cron

$ sudo -u www-data crontab -e
  */15 * * * * wget -O - -q -t 1 https://dbopen.ba.cnr.it/cron/******************

Import/export config

Enable import/export from UI

$ vendor/bin/drush en config

Or import/export configuration by drush

config:export --destination=/home/user/backup
config:import --partial --source=/home/user/upload

Enable composer patch

To be able to apply patch with composer we need:

$ composer require cweagans/composer-patches
  - Installing cweagans/composer-patches (1.7.0): Extracting archive

Private filesystem

$ mkdir /var/www/html/private
$ sudo chgrp -R www-data /var/www/html/private
$ nano -w web/sites/default/settings.php
  $settings['file_private_path'] = '/var/www/html/private';
$ vendor/bin/drush cr

S3fs and connect to Minio

Your PHP must be configured with allow_url_fopen = On in your php.ini file. Otherwise, PHP will be unable to open files that are in your S3 bucket.

$ grep -R allow_url_fopen /etc/php/*
/etc/php/7.4/fpm/php.ini:allow_url_fopen = On
/etc/php/7.4/cli/php.ini:allow_url_fopen = On

In addition, you need the php5-curl library installed for the SDK to be able to communicate with S3. Most hosts will already have this library installed, but some don't.

$ php -m |grep curl
curl

Install s3fs module

$ cd /var/www/html
$ composer require 'drupal/s3fs:3.x-dev@dev'
  - Installing mtdowling/jmespath.php (2.6.0): Extracting archive
  - Installing aws/aws-sdk-php (3.173.22): Extracting archive
  - Installing drupal/s3fs (dev-3.x 012cdc2): Cloning 012cdc22d5 from cache
$ vendor/bin/drush en s3fs
$ vendor/bin/drush cr

Configure settings.php

$ nano -w web/sites/default/settings.php
/**
 * Minio S3 credentials
 */
$settings['s3fs.access_key'] = 'my_access_key';
$settings['s3fs.secret_key'] = 'my_secret_key';
$config['s3fs.settings']['bucket'] = 'archipelago';

Browse UI at admin/config/media/s3fs

Custom Host Settings
Hostname => localhost:9000
Use path-style endpoint => YES

Theme

Install Barrio with subtheme

$ cd /var/www/html
$ composer require drupal/bootstrap_barrio
Using version ^5.1 for drupal/bootstrap_barrio
Lock file operations: 2 installs, 0 updates, 0 removals
  - Locking drupal/bootstrap_barrio (5.1.4)
  - Locking twbs/bootstrap (v4.6.0)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing twbs/bootstrap (v4.6.0): Extracting archive
  - Installing drupal/bootstrap_barrio (5.1.4): Extracting archive
cd web/themes/contrib/bootstrap_barrio/
chmod +x scripts/create_subtheme.sh
./scripts/create_subtheme.sh

Browse UI at admin/appearance

Install and set default Archipelago DBOpen theme (subtheme)

For administration UI

$ vendor/bin/drush en toolbar

Twig and Display suite modules

Install with composer and enable by drush.

$ composer require 'drupal/twig_field:^1.1' 'drupal/bamboo_twig:^5.0@alpha' 'drupal/twig_tweak:^3.0'
  - Installing drupal/bamboo_twig (5.0.0-alpha1): Extracting archive
  - Installing drupal/codemirror_editor (1.7.0): Extracting archive
  - Installing drupal/twig_field (1.1.0): Extracting archive
  - Installing drupal/twig_tweak (3.0.0): Extracting archive
$ vendor/bin/drush en twig_field
The following module(s) will be enabled: twig_field, codemirror_editor, editor
$ vendor/bin/drush en twig_tweak
$ composer require 'drupal/ds:^3.10'
  - Installing drupal/ds (3.10.0): Extracting archive
$ vendor/bin/drush en ds ds_extras ds_switch_view_mode
The following module(s) will be enabled: ds, ds_extras, ds_switch_view_mode, layout_discovery
 
$ composer require 'drupal/display_field_copy:^2.0'
  - Installing drupal/display_field_copy (2.0.0): Extracting archive
$ vendor/bin/drush en display_field_copy

Search API and Search API Solr

Install modules.

$ composer require 'drupal/search_api:^1.19'
  - Installing drupal/search_api (1.19.0): Extracting archive
$ vendor/bin/drush en search_api
 
$ composer require 'drupal/search_api_autocomplete:^1.4' 'drupal/search_api_attachments:^1.0@beta'
  - Installing drupal/search_api_attachments (1.0.0-beta17): Extracting archive
  - Installing drupal/search_api_autocomplete (1.4.0): Extracting archive
$ vendor/bin/drush en search_api_autocomplete search_api_attachments
 
$ composer require 'drupal/search_api_solr:^4.1'
  - Installing psr/http-client (1.0.1): Extracting archive
  - Installing psr/event-dispatcher (1.0.0): Extracting archive
  - Installing solarium/solarium (6.1.1): Extracting archive
  - Installing myclabs/php-enum (1.8.0): Extracting archive
  - Installing maennchen/zipstream-php (2.1.0): Extracting archive
  - Installing drupal/search_api_solr (4.1.11): Extracting archive
$ vendor/bin/drush en search_api_solr
The following module(s) will be enabled: search_api_solr, language

Browse UI to admin/config/search/search-api/add-server to add and configure Solr server

Solr Connector: Standard
Advanced: Retrieve result data from Solr = YES
Advanced: Retrieve highlighted snippets = YES
Advanced: Fallback to multiValued field types = YES

We have to add Language Undefined Text OCR Field with Coordinate highlight in Solr server Custom Field Type
Open https://github.com/esmero/archipelago-deployment/blob/1.0.0-RC2D9/config/sync/search_api_solr.solr_field_type.text_ocr_und_7_0_0.yml
Then browse UI at admin/config/development/configuration/single/import, select Solr Field type and paste yml above.

Add index browsing UI at admin/config/search/search-api/add-index

Name = [machine name] drupal_content_to_solr_8
Datasources
  Content = YES
  File = YES
Server = Solr DBOpen

Then SAVE (→ 1 doc on queue from datasource Content, so index, result = OK)
Set index Processors browsing UI at admin/config/search/search-api/index/drupal_content_to_solr_8/processors

Enable: Content access, Entity status, Highlight, HTML filter, Reverse entity references
Processor settings: Highlight and HTML filter

[we need to come back here after Strawberryfield installed] Then Reindexing (browse UI at admin/config/search/search-api/index/drupal_content_to_solr_8)
Fields will be added after Srawberryfield installed (dmin/config/search/search-api/index/drupal_content_to_solr_8/fields)

Views

$ composer require 'drupal/views_bootstrap:^4.3'
  - Installing drupal/views_bootstrap (4.3.0): Extracting archive
$ vendor/bin/drush en views views_ui views_bootstrap

Webform

$ composer require 'drupal/webform:^6'
  - Installing drupal/webform (6.0.2): Extracting archive
$ vendor/bin/drush en webform webform_bootstrap webform_image_select webform_node webform_ui
Successfully enabled: webform, webform_bootstrap, webform_image_select, webform_node, webform_ui, path
 
$ composer require 'drupal/webformnavigation:^1.0@alpha'
  - Installing drupal/webform_submission_log (6.0.2)
  - Installing drupal/webformnavigation (1.0.0-alpha11): Extracting archive
$ vendor/bin/drush en webformnavigation
Successfully enabled: webformnavigation, webform_submission_log

To avoid warnings in Status report

$ composer require 'drupal/recaptcha_element'
  - Installing google/recaptcha (1.2.4): Extracting archive
  - Installing drupal/recaptcha_element (1.0.5): Extracting archive
vendor/bin/drush en recaptcha_element
Successfully enabled: recaptcha_element

Libraries, see https://www.drupal.org/node/3003140

$ composer require wikimedia/composer-merge-plugin
  - Installing wikimedia/composer-merge-plugin (v2.0.1)
 
$ nano -w composer.json
    "extra": {
        "merge-plugin": {
            "include": [
                "web/modules/contrib/webform/composer.libraries.json"
            ]
        },
$ composer update drupal/webform
  - Installing algolia/places (1.19.0): Extracting archive
  - Installing choices/choices (9.0.1): Extracting archive
  - Installing ckeditor/autogrow (4.14.1): Extracting archive
  - Installing ckeditor/codemirror (v1.17.12): Extracting archive
  - Installing ckeditor/fakeobjects (4.14.1): Extracting archive
  - Installing ckeditor/image (4.14.1): Extracting archive
  - Installing ckeditor/link (4.14.1): Extracting archive
  - Installing codemirror/codemirror (5.53.2): Extracting archive
  - Installing jquery/chosen (1.8.7): Extracting archive
  - Installing jquery/geocomplete (1.7.0): Extracting archive
  - Installing jquery/hotkeys (0.2.0): Extracting archive
  - Installing jquery/icheck (1.0.2 ): Extracting archive
  - Installing jquery/image-picker (0.3.1): Extracting archive
  - Installing jquery/inputmask (5.0.5): Extracting archive
  - Installing jquery/intl-tel-input (16.1.0): Extracting archive
  - Installing jquery/rateit (1.1.3): Extracting archive
  - Installing jquery/select2 (4.0.13): Extracting archive
  - Installing jquery/textcounter (0.9.0): Extracting archive
  - Installing jquery/timepicker (1.13.14): Extracting archive
  - Installing jquery/toggles (4.0.0): Extracting archive
  - Installing progress-tracker/progress-tracker (2.0.6): Extracting archive
  - Installing signature_pad/signature_pad (2.3.0): Extracting archive
  - Installing svg-pan-zoom/svg-pan-zoom (3.6.1): Extracting archive
  - Installing tabby/tabby (12.0.3): Extracting archive
  - Installing tippyjs/5.x (5.2.1)
  - Installing tippyjs/6.x (6.2.6)

Form Mode Manager with patches

Partially follow this post https://www.computerminds.co.uk/articles/apply-drupal-9-compatibility-patches-composer
Add package source from git to avoid composer block to install

$ nano -w composer.json
    },
    "repositories": [
    {
      "type": "package",
      "package": {
        "name": "drupal/form_mode_manager",
        "type": "drupal-module",
        "version": "dev-8.x-2.x",
        "source": {
          "type": "git",
          "url": "https://git.drupalcode.org/project/form_mode_manager.git",
          "reference": "bb634122"
        }
      }
    },

Add patch links to composer.json

            "web/themes/custom/{$name}": [
                "type:drupal-custom-theme"
            ]
        },
        "enable-patching": true,
        "patches": {
            "drupal/form_mode_manager": {
                "Fix Form Mode title": "https://www.drupal.org/files/issues/2019-12-10/form_mode_manager-bundle-label-in-title-3100112-2-D8.patch",
                "D9 readyness": "https://www.drupal.org/files/issues/2020-10-30/form_mode_manager-drupal-9-compatibility-3164478-6.patch"
            },
            "drupal/role_theme_switcher": {
                "D9 readyness": "https://www.drupal.org/files/issues/2020-06-06/role_theme_switcher.1.x-dev.rector.patch"
            }
        }

Then it can be installed and patches applied

$ composer -v require drupal/form_mode_manager
 Using version dev-8.x-2.x for drupal/form_mode_manager
...
  - Installing drupal/form_mode_manager (dev-8.x-2.x bb634122): Cloning bb634122 from cache
...
  - Applying patches for drupal/form_mode_manager
    https://www.drupal.org/files/issues/2019-12-10/form_mode_manager-bundle-label-in-title-3100112-2-D8.patch (Fix Form Mode title)
    https://www.drupal.org/files/issues/2020-10-30/form_mode_manager-drupal-9-compatibility-3164478-6.patch (D9 readyness)
 
$ vendor/bin/drush en form_mode_manager

Workflow

We need patch as stated here https://github.com/esmero/archipelago-deployment/issues/100

$ nano -w composer.json
        "patches": {
            "drupal/workflow": {
                "D9 readyness": "https://www.drupal.org/files/issues/2020-07-07/deprecated_entity_manager_workflowstorage_error-3157199-7.patch"
            },
$ composer require 'drupal/workflow'
  - Installing drupal/workflow (1.4.0): Extracting archive
  - Applying patches for drupal/workflow
    https://www.drupal.org/files/issues/2020-07-07/deprecated_entity_manager_workflowstorage_error-3157199-7.patch (D9 readyness)
 
$ vendor/bin/drush en workflow
Successfully enabled: workflow

Token UUID

$ composer require drupal/tokenuuid
  - Installing drupal/token (1.9.0): Extracting archive
  - Installing drupal/tokenuuid (1.4.0): Extracting archive
$ vendor/bin/drush en tokenuuid
Successfully enabled: tokenuuid, token

Web Services

$ vendor/bin/drush en hal jsonapi rest serialization
 
$ composer require 'drupal/restui'
  - Installing drupal/restui (1.19.0)
$ vendor/bin/drush en restui
Successfully enabled: restui
  • stepbystep/drupal.1615223002.txt.gz
  • Last modified: 2021/03/08 18:03
  • by giancarlo