Qadry
unixcop Admin

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

Introduction

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)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> \q
Bye
[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 http://rpms.remirepo.net/enterprise/remi-release-7.rpm
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 https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
[root@unixcop ~]# wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
--2021-08-24 07:16:26--  https://www.drupal.org/download-latest/tar.gz
Resolving www.drupal.org (www.drupal.org)... 151.101.2.217, 151.101.66.217, 151.101.130.217, ...
Connecting to www.drupal.org (www.drupal.org)|151.101.2.217|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://ftp.drupal.org/files/projects/drupal-9.2.5.tar.gz [following]
--2021-08-24 07:16:26--  https://ftp.drupal.org/files/projects/drupal-9.2.5.tar.gz
Resolving ftp.drupal.org (ftp.drupal.org)... 151.101.2.217, 151.101.66.217, 151.101.130.217, ...
Connecting to ftp.drupal.org (ftp.drupal.org)|151.101.2.217|: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>
     ServerName drupal.unixcop.com
     ServerAlias www.drupal.unixcop.com
     ServerAdmin admin@drupal.unixcop.com
     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]
     </Directory>
</VirtualHost>

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

x