Drupal Site Quickstart

Error message

  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in _menu_load_objects() (line 579 of /var/www/drupal-7.x/includes/menu.inc).
  • Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/drupal-7.x/includes/common.inc).
Published by Matthew Davidson on Sun, 04/09/2022 - 1:19pm in

Works with Drupal: ^8 || ^9

Create Database and User

mysql -u [user] -p

Where [user] has ALL PRIVILEGES globally

GRANT ALL PRIVILEGES ON [dbname].* TO [dbuser]@localhost IDENTIFIED BY '[password]';

Install Drupal Core from Composer

See Using Composer to Install Drupal and Manage Dependencies.

cd /var/www/
mkdir [dirname]
composer create-project drupal/recommended-project [dirname]

Install Drupal Core from a Git Repo You've Already Created*

* See below.

cd /var/www/
git clone [repo URI]

Rename this directory as required.

cd /var/www/[dirname]
composer i

Configure Apache

Config file template:

<VirtualHost *:80>
        ServerAdmin [you@domain]
        ServerName [fqdn]
        #ServerAlias www.[fqdn]
        RewriteEngine on
        RewriteCond  %{HTTP_HOST}  !^[fqdn]          [NC]
        RewriteCond  %{HTTP_HOST}  !^$
        RewriteRule  ^/(.*)        http://[fqdn]/$1  [L,R]

        #Uncomment if production server with HTTPS
        #RewriteCond %{SERVER_NAME} =[fqdn] [OR]
        #RewriteCond %{SERVER_NAME} =[fqdn]
        #RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

        DocumentRoot /var/www/[dirname]/web
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        <Directory /var/www/[dirname]/web>
                RewriteEngine on
                RewriteBase /
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined
        ServerSignature On


Drupal initial setup

cd /var/www/[dirname]
mkdir -p config/sync
mkdir db
cd /var/www/[dirname]/web/sites/default/
mkdir files
cp default.settings.php settings.php

Set this value in settings.php:

$settings['config_sync_directory'] = '/var/www/[dirname]/config/sync';

Also set trusted hosts.

sudo chown www-data:www-data files/ settings.php

Run Drupal installer

sudo chown [you]:staff settings.php
sudo chmod 664 settings.php
composer require drush/drush drupal/devel drupal/admin_toolbar

See also Drush Launcher.

sudo -u www-data drush en devel admin_toolbar media_library layout_builder

(Running as www-data because media module needs to create a directory in 'files'.)

SSL Certificate

sudo certbot --apache

(On live sites only, obviously.)

[Todo: git stuff.]



drush sql:dump | gzip > /var/www/[dirname]/db/[whatever].sql.gz


drush sql:drop
drush sqlq --file=/var/www/[dirname]/[whatever].sql.gz