We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – How To Install Drupal 10 CMS on Debian 11 / Debian 10

Learn how to – How To Install Drupal 10 CMS on Debian 11 / Debian 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 e.t.c. Drupal has over 17,000 addons/plugins to increase its functionality. it ships widgets, preinstalled themes, and other features that help one to get started with web programming, thus ideal for users with little web programming background knowledge.

Drupal 10 is most recent release of Drupal content management system (CMS). This version was released on June 3, 2021. Drupal 10 includes new features such as improved accessibility, better performance, and updated core modules. Some of the features in Drupal 10 are listed below.

  • Improved accessibility: This includes improved color contrast and keyboard navigation.
  • PHP 8 support: Drupal 10 require PHP 8.1
  • Improvement on performance: This new release comes with improved caching and faster page load times.
  • Updated core modules: Many updates on the core modules, such as the Media module which improves its performance and functionality.
  • Multilingual enhancements: Improved support for multilingual sites, and translation management.
  • Modern web technologies: Drupal 10 native support of the latest web technologies, including HTML5, CSS3 and JavaScript.

System Requirements.

For you to be able to install Drupal on Debian 11 / Debian 10, you will require the following.

  • PHP (the recommended versions for Drupal 10 are PHP 8.1 and above)
  • Database server – MySQL, MariaDB, PostgreSQL, Percona, SQLite e.t.c.
  • Web Server – Nginx, Apache, Caddy e.t.c

Update your system and install the required packages.

sudo apt update && sudo apt -y full-upgrade
[ -f /var/run/reboot-required ] && sudo reboot -f

Now let’s dive in!

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

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

Add Ondřej Surý’s PHP PPA to your system.

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list
curl -fsSL  https://packages.sury.org/php/apt.gpg| sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/sury-keyring.gpg

Install PHP Apache web server and MariaDB database server.

sudo apt install vim wget curl apache2 mariadb-server mariadb-client

Install PHP 8.1 packages on the system.

sudo apt install php8.1 libapache2-mod-php8.1 php8.1-{fpm,cli,mysql,zip,gd,intl,mbstring,curl,xml,soap,tidy,bcmath,xmlrpc} 

Verify the installed PHP version.

$ php -v
PHP 8.1.14 (cli) (built: Jan 13 2023 10:38:02) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.14, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.14, Copyright (c), by Zend Technologies

Enable mod rewrite for Apache.

sudo a2enmod rewrite
sudo systemctl restart apache2

Verify the module has been enabled.

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

Now that all the required packages have been installed, let’s begin by configuring our database.

Step 2 – Configure MariaDB for Drupal 10 CMS on Debian

Once MariaDB is installed, it is not secure, we need to harden it by setting the root password as below.

Start and enable MariaDB.

sudo systemctl enable --now mariadb

Harden MariaDB

sudo mysql_secure_installation

Proceed as 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 the password set above and proceed to the MariaDB shell. Once in the shell, issue the below command to create a database for Drupal 9 CMS.

CREATE DATABASE drupal CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

We have created a database with the name, drupal now create a database user and grant the user full access to the database.

CREATE USER drupal@localhost IDENTIFIED BY "StrongDBPassw0rd";
GRANT ALL ON drupal.* TO drupal@localhost IDENTIFIED BY "StrongDBPassw0rd";
FLUSH PRIVILEGES;
QUIT

Step 3 – Download Drupal 10 CMS on Debian 11/ Debian 10

Download the latest release version of Drupal from the Drupal release page. As of this guide, the latest available version was Drupal 10.x which can also be pulled using Wget as below.

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

Now that you have downloaded the archive, proceed and extract it.

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

Move the extracted folder to the Apache directory at /var/www/html

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

Set the permissions of the directory as below.

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

Disable default website:

sudo a2dissite 000-default.conf
sudo systemctl restart apache2

Step 4 – Create the Apache Virtual Host for Drupal 9

For the Drupal 9 site to serve, we need to create a virtual host file for Apache. Create the Virtual Host file on Debian 11/Debian 10 as below.

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

In the configuration file, add the lines below replacing appropriately.

<VirtualHost *:80>
    ServerAdmin admin@example.com
    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 with your domain name. Enable your site.

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

Restart Apache for the changes made to apply.

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

In case you cannot access the page, you might be required to move the default apache conf to a backup file as 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 the Web UI

The final step in our Drupal 9 CMS installation is setting it on the browser. On your favorite browser, access the site using the URL http://server-ip/ or http//hostname

On this page, you will be required to set your preferred language. Then proceed to the next page where you are required to select a profile from the 3 Drupal installation profiles. Here, simply go for the standard profile.

Next, configure your Drupal 9 database. Enter the credentials for the database we created earlier.

Once done, click save and continue and the Drupal 9 installation will proceed as below.

Once complete, you will be granted the below page, where you are required to provide the details for your site.

With everything done, you should be able to see this Drupal 9 welcome page.

That is it! From here, you are set to create blog websites with various templates provided.

Click add content and choose the type of content to add either an article or a basic page.

You can also customize your Drupal 9 appearance as below.

Step 6 – (Optional) Secure Drupal 9 CMS with Let’s Encrypt SSL

Accessing the site using HTTP is normally not secure and you might need to secure it to be able to access the site using HTTPS. In this guide, we will use Let’s Encrypt is to issue trusted SSL certificates for our FQDN. Before proceeding, ensure that you have an FQDN.

Install Certbot on Debian 11/10 as below.

sudo apt install certbot python3-certbot-apache2

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

$ sudo vim /etc/apache2/sites-available/drupal.conf
........
<VirtualHost *:443>
    ServerName example.com
ServerAdmin admin@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>

Restart apache.

sudo systemctl restart apache2

Now install trusted certificates on Debian 11/10 as below.

sudo certbot --apache

Proceed as 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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

With the certificates installed, your apache conf file should be as below.

$ sudo cat /etc/apache2/sites-available/drupal.conf
<VirtualHost *:80>
    ServerAdmin admin@example.com
    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 admin@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 
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 proceed and access your Drupal site using HTTPS with the URL https://hostname.

My site is secure as symbolized with a “padlock icon“.

Conclusion.

That marks the end of this guide on how to install and configure Drupal 9 CMS on Debian 11 / Debian 10. I hope this guide was significant.

See more on this page:

Cart

Your Cart is Empty

Back To Shop