How To Install and Configure The Latest release of Drupal on CentOS 7/8


Drupal is a free and open-source web content management system (CMS) written in PHP and distributed under the GNU General Public License. Drupal provides a back-end framework for at least 13% of the top 10,000 websites worldwide – ranging from personal blogs to corporate, political, and government sites. Systems also use Drupal for knowledge management and for business collaboration.

The minimum requirements for running Drupal 9 on CentOS 8:

  • PHP >=7.3
  • MySQL or Percona, version >=5.7.8
  • MariaDB >=10.3.7
  • PostgreSQL >=10

Install and Configure Drupal 9

In this section we will cover installation of dependencies required to run Drupal on CentOS 8

Install Database server

Choose a database server you want to use, this can be MySQL, MariaDB or PostgreSQL. In this guide we will use MariaDB database server.

Update and reboot your system before database installation:

sudo yum -y update
sudo systemctl reboot

Create Drupal Database

Open MariaDB shell with running this command below:

$ mysql -u root -p

Then create database and user for Drupal with mariadb commands as shown:

[root@unixcop ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE db_drupal;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE USER 'user_drupal' IDENTIFIED BY 'unixcoppassword';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT ALL ON db_drupal.* TO 'user_drupal'@'localhost' IDENTIFIED BY 'unixcoppassword';
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> \q
[root@unixcop ~]# 

Install PHP and required extensions

Also we need to install PHP 7.3 or higher version for Drupal 9. these repositories are required

So we will add them with commands:

yum -y install
yum -y install epel-release

Then enable PHP 7.3 repository with:

yum -y install yum-utils
yum-config-manager --disable remi-php54
yum-config-manager --enable remi-php73

Install PHP 7.3 on CentOS 8 as shown below:

# yum -y install php php-{cli,gd,mysqlnd,mbstring,json,common,dba,dbg,devel,embedded,enchant,bcmath,gmp,intl,ldap,odbc,pdo,opcache,pear,pgsql,process,recode,snmp,soap,xml,xmlrpc}

Drupal requires additional PHP modules to function without a hitch. So install them by executing the command below.

# yum install php-curl php-mbstring php-gd php-xml php-pear php-fpm php php-mysql php-pdo php-opcache php-json php-zip

Install Web Server

We’ll configure Apache as Web server for Drupal 9:

yum -y install httpd

Set PHP Timezone and memory limit.

vim /etc/php.ini
memory_limit = 256M
date.timezone = Africa/Cairo

Start and enable httpd service.

systemctl enable --now httpd

Download Drupal 9

Download the Drupal 9 tar files … use the command below to install the latest version of Drupal:

wget -O drupal.tar.gz
[root@unixcop ~]# wget -O drupal.tar.gz
--2021-08-24 07:16:26--
Resolving (,,, ...
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: [following]
--2021-08-24 07:16:26--
Resolving (,,, ...
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18859934 (18M) [application/octet-stream]
Saving to: ‘drupal.tar.gz’

100%[============================================================================================================>] 18,859,934  57.6MB/s   in 0.3s   

2021-08-24 07:16:27 (57.6 MB/s) - ‘drupal.tar.gz’ saved [18859934/18859934]

[root@unixcop ~]# ls

As shown above the latest version of Drupal while we are editing this article is drupal-9.2.5

Then extract downloaded file:

tar -xvf drupal.tar.gz

Remove the Drupal tarball then move extracted folder to /var/www/html with commands

rm -f drupal*.tar.gz
mv drupal-*/  /var/www/html/drupal

Also create the directories and files required by Drupal with commands below:

mkdir /var/www/html/drupal/sites/default/files
cp /var/www/html/drupal/sites/default/default.settings.php /var/www/html/drupal/sites/default/settings.php

Edit ownership of drupal files to Apache user

sudo chown -R apache:apache /var/www/html/
sudo chmod -R 755 /var/www/html/

Then make SELinux permissive temporariley with

setenforce 0

Configure Apache for Drupal

Create a new Apache configuration for Drupal website.

vim /etc/httpd/conf.d/drupal.conf

Add the following :

<VirtualHost *:80>
     DocumentRoot /var/www/html/drupal/

     CustomLog /var/log/httpd/access_log combined
     ErrorLog /var/log/httpd/error_log

     <Directory /var/www/html/drupal>
            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]

Then restart httpd

systemctl restart httpd

Install Drupal 9

Open web browser to finish the installation of Drupal 9 and follow the steps as per in the screenschots.

Choose an installation Language

Choose installation profile

Set Database access details as configured earlier

Configure the site

Finally, as shown above you’ll be directed to website admin panel.

That’s all, Thank you

unixcop Admin


Please enter your comment!
Please enter your name here

Latest articles

You might also likeRELATED

How to Count Number of Files and Sub-directories inside a Directory

Hi guys, In this article we will show you how to count the number of files and sub-directories in a directory using a tree command. Count number...

Find Top 10 IP Addresses Accessing Your Apache Web Server

In this post, you will learn how to Find Top 10 IP Addresses Accessing Your Apache Web Server- The monitoring access to your web server...

How to Install MongoDB in CentOS 8

Introduction MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License (SSPL). MongoDB is a...