At the mention of popular content management systems, Drupal usually ranks among the top and most widely used systems.
Written in PHP, Drupal is an open-source and free CMS that is used for creating stunning blogs and websites.
It provides a wide variety of tools, templates, and plugins to create powerful and elegant websites with excellent security and reliability.
It's both a backend and front-end platform, with the backend riding on MySQL database and the front-end powered by PHP and Javascript.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to resolve related Drupal errors.
In this context, we shall look into how to install Drupal on Debian 10, Buster.
Before proceeding with this installation procedure, ensure that you are using a configured sudo user to perform privileged tasks on an instance of Debian 10 with SSH access.
Then, follow the steps given below.
Drupal is written in PHP, and just like any other CMS such as WordPress that stores data in a MySQL or MariaDB database and is accessed from a browser, it requires a LAMP stack to work.
LAMP comprises the popular Apache web server, MySQL (or MariaDB) database, and PHP scripting engine.
We already have an elaborate guide on how to install LAMP on Linux Mint.
Once you have the LAMP server installed, proceed to the next step.
A database for Drupal is mandatory because it will store the installation files as well as other data after installation.
Our database engine of choice is MariaDB which is a fork of MySQL and provides the latest clustering technology and high-performance storage engines.
i. To log in to the MariaDB shell, run the command:
$ sudo mysql -u root -p
ii. Begin by creating a database called mydrupaldb.
Of course, you are liberty to provide your preferred database name:
> CREATE DATABASE mydrupaldb;
iii. Next, create a database user for the Drupal database:
> CREATE USER 'mydrupal_user'@'localhost' IDENTIFIED BY 'user_password';
iv. Be sure to grant all the privileges to the database user on the Drupal database.
> GRANT ALL ON mydrupaldb.* TO 'mydrupal_user'@'localhost' IDENTIFIED BY 'user_password';
v. Then, save the changes and exit.
> FLUSH PRIVILEGES
> EXIT
The database for our Drupal installation is in place. Let's plod along and now grab a copy of the Drupal installation file.
i. Next, access the official download page for Drupal https://www.drupal.org/download and download the tarball file as shown:
$ wget https://www.drupal.org/download-latest/tar.gz
ii. Next, extract the compressed file to the webroot directory as provided:
$ sudo tar -xvf drupal.tar.gz -C /var/www/html
iii. This takes a few seconds and extracts hundreds of files into a folder labeled drupal-9.1.6.
iv. Let's rename the directory to drupal to make our configuration easier:
$ sudo mv /var/www/html/drupal-9.1.6 /var/www/html/drupal
v. Next, set the directory ownership of the drupal directory to www-data user:
$ sudo chown -R www-data:www-data /var/www/html/drupal
vi. Thereafter, configure the directory permissions as follows to allows read and execute permissions to all users:
$ sudo chmod -R 775 /var/www/html/drupal
With the right set of permissions in place, let's proceed and create a virtual host file for our Drupal instance.
The last part is to create a configuration file or virtual host file for Drupal.
i. So, using your favorite text editor, create the file below.
$ sudo vim /etc/apache2/sites-available/drupal.conf
The ServerName attribute can take either your IP address or domain name if you have an FQDN pointed to the IP of your Debian 10 instance.
ii. Add the lines shown below:
<VirtualHost *:80>
ServerAdmin webmaster@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>
Where:
i. example.com is your site domain
ii. /var/www/html/drupal is the location of Drupal files
iii. /var/log/apache2/ is the location of Apache log files
For https access, check Drupal SSL Configuration guide.
iii. Once done, save and exit the Drupal config file. Next, enable the Drupal virtual host as follows:
$ sudo a2ensite drupal.conf
iv. Then invoke the a2enmod script file to enable the Apache module rewrite as shown:
$ sudo a2enmod rewrite
v. To effect the changes, reload or restart Apache.
$ sudo systemctl restart apache2
Next, we will complete setup from a web browser.
From your web browser, follow the URL shown:
http://server-IP or domain-name
From here, Select your language as provided by the welcome page.
Next, three installation profiles will be provided.
To keep it simple, select the 'Standard' profile.
Next, provide the database details that you provided in Step 2.
Next, provide your site's details with information such as the site name, email address, username, and password to the Drupal account.
Scroll and click on 'Save and continue' at the very bottom.
The installation will begin as the installer installs all of Drupal's packages and modules.
Once done, you will be ushered to Drupal's dashboard.
From here, you can proceed and create your website or blog using various templates that Drupal provides.
This article covers how to setup Drupal on Debian Linux System.
Drupal is a powerful CMS that allows you to design stunning websites and blogs with simple tools and drag and drop features in a matter of a few hours.
It offers flexibility in terms of customization of your site to meet your desired results.
You can easily get started with free templates before advancing to premium templates that have more features.
To Configure Apache 2.4:
1. Enable Apache's rewrite module. This module is necessary since Drupal 8 enables Clean URLs by default;
$ sudo a2enmod rewrite
2. Specify the rewrite conditions for your Drupal site’s document root in Apache's configuration file using the text editor of your choice.
If you installed and configured your Apache server using LAMP stack on Debian 10 guide, the configuration file for your site is located at /etc/apache2/sites-available/example.com.conf.
File: /etc/apache2/sites-available/example.com.conf:
<Directory /var/www/html/example.com/public_html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
3. Change the ownership of your site's document root from root to www-data. This allows you to install modules and themes, and to update Drupal, without being prompted for FTP credentials.
$ sudo chown -R www-data:www-data /var/www/html/example.com
4. Restart Apache so all changes are applied.
$ sudo systemctl restart apache2