Install and configure Drupal 9 CMS on Debian 11|10

Drupal is a free and open source content management system written in PHP. It is used to create and manage online content, such as blogs, websites, etc. Drupal has more than 17,000 plugins/plugins to increase its functionality. It provides widgets, pre-installed themes, and other functions that help start web programming, so it is very suitable for users with little background knowledge of web programming.

The latest version of Drupal CMS is the 9th version released in June 2020. This new version of Drupal 9 CMS has the following features:

  • Backward compatible – This just means that Drupal 9 is compatible with its predecessor, Drupal 8.
  • With multilingual capabilities, BigPipe, structured content, and content workflows, you can identify multiple workflows to achieve faster and better performance.
  • Not deprecated
  • Windows development, able to run on Windows Web server.
  • Headless CMS, which helps to build a powerful front-end website using JavaScript framework

In this guide, we will install and configure Drupal 9 CMS on Debian 11 / Debian 10.

System Requirements.

In order to be able to install Drupal on Debian 11 / Debian 10, you need to have the following requirements.

  • PHP (The recommended version of Drupal 9 is PHP 7.3 and above)
  • Database server-MySQL, MariaDB, PostgreSQL, Percona, SQLite, etc.
  • Web server-Nginx, Apache, Caddy, etc.

Update your system and install the required software packages.

sudo apt update && sudo apt upgrade
sudo apt install wget vim

Let’s dive in now!

Step 1-Install LAMP Stack on Debian 11/ Debian 10

In this guide, we will use Apache Web server, PHP and MariaDB database can all be installed on our Debian 11/Debian 10 system using the following APT command.

sudo apt install apache2 mariadb-server mariadb-client php libapache2-mod-php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-intl php-mbstring php-curl php-xml php-pear php-tidy php-soap php-bcmath php-xmlrpc 

Verify the installed PHP version.

$ php -v
PHP 7.4.21 (cli) (built: Jul  2 2021 03:59:48) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies

Enable mod rewrite Apache.

sudo a2enmod rewrite
sudo systemctl restart apache2

Verify that the module is enabled.

$ sudo apache2ctl -M | grep rewrite
rewrite_module (shared)

Now that all the necessary packages have been installed, let’s start configuring our database.

Step 2-Configure MariaDB for Drupal 9 CMS on Debian 11/Debian 10.

After MariaDB is installed, it is not safe, we need to strengthen it by setting the root password, as shown below.

Start and enable MariaDB.

sudo systemctl enable --now mariadb

Strengthen MariaDB

sudo mysql_secure_installation

Please follow the steps below.

Enter current password for root (enter for none): Press Enter
....
Switch to unix_socket authentication [Y/n] y
.......
Change the root password? [Y/n] y
New password: Enter Password
Re-enter new password: Re-Enter Password
......
Remove anonymous users? [Y/n] y
...
Disallow root login remotely? [Y/n] y
...
...
Remove test database and access to it? [Y/n] y
....
Reload privilege tables now? [Y/n] y
.....
Thanks for using MariaDB!

Now create a database for Drupal 9 CMS on Debian 11/Debian 10

sudo mysql -u root -p

Enter Set the password above and continue to MariaDB shell. After entering the shell, issue the following command to create a database for Drupal 9 CMS.

MariaDB [(none)]> CREATE DATABASE drupal CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

We have created a database named Drupa Now create a database user and grant this user full access to the database.

CREATE USER drupal@localhost IDENTIFIED BY "StrongDBPassw0rd";
GRANT ALL ON drupal.* TO [email protected] IDENTIFIED BY "Passw0rd";
FLUSH PRIVILEGES;
QUIT

Step 3-Download Drupal 9 CMS on Debian 11/Debian 10.

Download the latest release of Drupal from the following location Drupal release page. In this guide, the latest available version is Drupal 9.2.7 You can also use Wget to pull, as shown below.

DRUPAL_VERSION="9.2.7"
wget https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.tar.gz

Now that you have downloaded the archive, go ahead and unzip it.

tar xvf drupal-${DRUPAL_VERSION}.tar.gz

Move the unzipped folder to Apache Catalog in /var/www/html

sudo mv drupal-${DRUPAL_VERSION} /var/www/html/drupal

Set the permissions of the directory as follows.

sudo chown -R www-data:www-data  /var/www/html/drupal

Step 4-Create Apache Drupal 9 virtual host

In order to serve the Drupal 9 site, we need to create a virtual host file Apache. Create a virtual host file on Debian 11/Debian 10 as shown below.

sudo vim /etc/apache2/sites-available/drupal.conf

In the configuration file, add the following line and replace as appropriate.

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    DocumentRoot /var/www/html/drupal
    <Directory /var/www/html/drupal/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog /var/log/apache2/drupal_error.log
    CustomLog /var/log/apache2/drupal_access.log combined
</VirtualHost>

In the conf file, replace example.com Use your domain name. Activate your website.

sudo ln -s /etc/apache2/sites-available/drupal.conf /etc/apache2/sites-enabled/drupal.conf

restart Apache For the changes to be applied.

sudo systemctl restart apache2

Check the status of the service.

$ systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-10-22 06:16:13 EDT; 7s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 32050 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 32055 (apache2)
      Tasks: 6 (limit: 7075)
     Memory: 15.3M
        CPU: 46ms
     CGroup: /system.slice/apache2.service
             ├─32055 /usr/sbin/apache2 -k start
             ├─32056 /usr/sbin/apache2 -k start
             ├─32057 /usr/sbin/apache2 -k start
             ├─32058 /usr/sbin/apache2 -k start
             ├─32059 /usr/sbin/apache2 -k start
             └─32060 /usr/sbin/apache2 -k start

If you cannot access the page, you may need to move the default apache conf to the backup file as shown below.

sudo mv /etc/apache2/sites-enabled/000-default.conf /etc/apache2/sites-enabled/000-default.conf.bak
sudo systemctl restart apache2

Step 5-Configure Drupal 9 CMS via Web UI

The last step of Drupal 9 CMS installation is to set it up on the browser.On your favorite browser, use the URL https://server-ip/ or http//hostname

On this page, you need to set your preferred language. Then go to the next page, you need to choose a configuration file from 3 Drupal installation configuration files.Here just go standard contour.Install and configure Drupal 9 CMS on Debian 11 Debian 10 1

Next, configure your Drupal 9 database. Enter The credentials of the database we created earlier.Install and configure Drupal 9 CMS on Debian 11 Debian 10 9

Once completed, Click save and continue The Drupal 9 installation will proceed as follows.Install and configure Drupal 9 CMS on Debian 11 Debian 10 3

Upon completion, you will be awarded the following page where you need to provide the site details.Install and configure Drupal 9 CMS on Debian 11 Debian 10 4

After completing all the operations, you should be able to see this Drupal 9 welcome page.Install and configure Drupal 9 CMS on Debian 11 Debian 10 5

now it’s right! From here, you can create a blog site using the various templates provided.Install and configure Drupal 9 CMS on Debian 11 Debian 10 6

Click on Add content And select the content type of the article or basic page you want to add.Install and configure Drupal 9 CMS on Debian 11 Debian 10 7

You can also customize the appearance of your Drupal 9 as shown below.Install and configure Drupal 9 CMS on Debian 11 Debian 10 8

Step 6-(Optional) Use a secure Drupal 9 CMS Let’s Encrypt Security certificate

Accessing a site using HTTP is generally not secure, and you may need to protect it to access the site using HTTPS.In this guide, we will use Let’s Encrypt Is to issue a trusted SSL certificate for our FQDN. Before proceeding, make sure you have an FQDN.

Install Certbot on Debian 11/10 as shown below.

sudo apt install certbot python3-certbot-apache2

Configure your apache configuration by adding the following lines at the bottom.

$ sudo vim /etc/apache2/sites-available/drupal.conf
........
<VirtualHost *:443>
    ServerName example.com
ServerAdmin [email protected]
    DocumentRoot /var/www/html/drupal
    <Directory /var/www/html/drupal/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog /var/log/apache2/drupal_error.log
    CustomLog /var/log/apache2/drupal_access.log combined
</VirtualHost>

Restart Apache.

sudo systemctl restart apache2

Now install the trusted certificate on Debian 11/10 as shown below.

sudo certbot --apache

Please follow the steps below.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): Enter a valid Email address here          

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y
Account registered.

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1

Requesting a certificate for bitwarden.example.com
Performing the following challenges:
http-01 challenge for example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/apache2/sites-available/drupal.conf
Redirecting all traffic on port 80 to ssl in /etc/apache2/sites-available/drupal.conf

Successfully received certificate.
Certificate is saved at: a2enmod ssl
/etc/letsencrypt/live/example.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/example.com/privkey.pem
This certificate expires on 2022-01-09.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

After installing the certificate, your apache conf file should look like the following.

$ sudo cat /etc/apache2/sites-available/drupal.conf
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    DocumentRoot /var/www/html/drupal
    <Directory /var/www/html/drupal/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog /var/log/apache2/drupal_error.log
    CustomLog /var/log/apache2/drupal_access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
    ServerName example.com
ServerAdmin [email protected]
    DocumentRoot /var/www/html/drupal
    <Directory /var/www/html/drupal/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog /var/log/apache2/drupal_error.log
    CustomLog /var/log/apache2/drupal_access.log combined 
SSLCertificateFile /etc/letsencrypt/live/pw.hirebestengineers.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/pw.hirebestengineers.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

Now you can continue and visit your Drupal site using HTTPS with URL https://hostname.Install and configure Drupal 9 CMS on Debian 11 Debian 10 10

My website is safe, use “Padlock icon“.

in conclusion.

This marks the end of this guide on how to install and configure Drupal 9 CMS on Debian 11 / Debian 10. I hope this guide is important.

See more information on this page:

  • Use Drush command line shell to manage Drupal CMS
  • Install and configure Drupal on CentOS 7
  • How to install Drupal CMS on Ubuntu

Related Posts