Home Drupal CMS How to Install Drupal CMS in RHEL 8 Linux

How to Install Drupal CMS in RHEL 8 Linux

CMS platforms have an undisputed grip in the World Wide Web and Drupal qualifies as one of the unique candidates in this docket.

CMS platforms make it easier and more flexible to create and manage both the content and users that have partial/full administrative privilege on such content.

Also, CMS platforms like Drupal support numerous plugins to make your website more extensive. You get to create new/customizable web pages, comment sections, and other useful tweaks that will meet your CMS objectives.

Prerequisites

Ensure that you are a Sudoer/root user on the RHEL operating system you are using. Also, have a basic understanding of the Linux filesystem structure and how to use its command-line interface.

Installing Apache Web Server in RHEL

First, update your RHEL 8 system and install the Apache webserver.

$ sudo yum update
$ sudo dnf install httpd httpd-tools
Install Apache on RHEL
Install Apache on RHEL

After installation, you need to start, enable and start the apache web server.

$ sudo systemctl start httpd
$ sudo systemctl enable httpd
$ sudo systemctl status httpd
Check Apache Status in RHEL
Check Apache Status in RHEL

Installing MySQL Database in RHEL

We are going to use the MariaDB database, which is an open-source RDBMS.

$ sudo yum install mariadb-server
Install MySQL on RHEL
Install MySQL on RHEL

After installation, you need to start, enable and start the database server.

$ sudo systemctl start mariadb
$ sudo systemctl enable mariadb
$ sudo systemctl status mariadb
Check MySQL Status in RHEL
Check MySQL Status in RHEL

Next, you need to secure the database by executing the following security script.

$ sudo mysql_secure_installation

Once you execute the command, it will prompt you to set the root password and delete anonymous users, test databases, and disable remote root user login.

Secure MySQL on RHEL
Secure MySQL on RHEL

Installing PHP in RHEL

To install the latest version of PHP 8.1, you need to add EPEL and REMI repositories.

$ sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
$ sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Next, list the PHP module, which will show available PHP versions.

$ sudo dnf module list php
List PHP Modules
List PHP Modules

Reset the PHP module and enable the PHP module stream you wish to use e.g. PHP 8.1.

$ sudo dnf module reset php
$ sudo dnf module enable php:remi-8.1
Enable PHP Modules
Enable PHP Modules

Install PHP and its dependencies.

$ sudo dnf install php php-opcache php-gd php-curl php-mysqlnd php-mbstring php-xml php-pear php-fpm php-mysql php-pdo php-json php-zip php-common php-cli php-xmlrpc php-xml php-tidy php-soap php-bcmath php-devel 
Install PHP in RHEL
Install PHP in RHEL

After installation, you need to start, enable and start the php-fpm service.

$ sudo systemctl start php-fpm
$ sudo systemctl enable php-fpm
$ sudo systemctl status php-fpm
Check PHP-FPM Status in RHEL
Check PHP-FPM Status in RHEL

Next, enable Selinux to support Apache’s execution of PHP code via php-fpm.

$ sudo setsebool -P httpd_execmem 1

Creating MySQL Database for Drupal

Connect to MySQL database with the following command.

$ mysql -u root -p

Create a Drupal user, a Drupal database, and grant this user the needed database privileges.

MariaDB [(none)]> CREATE USER drupal@localhost IDENTIFIED BY "Your_drupal_user_password";
MariaDB [(none)]> CREATE DATABASE drupal;
MariaDB [(none)]> GRANT ALL ON drupal.* TO drupal@localhost;
MariaDB [(none)]> FLUSH PRIVILEGES; 
MariaDB [(none)]> EXIT;
Add Drupal Database
Add Drupal Database

Installing Drupal in RHEL

The default RHEL repository does not have Drupal as a package. Therefore, you need to download Drupal via the wget command.

$ wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz

Extract it and move it to the /var/www/html system directory.

$ tar -xvf drupal.tar.gz
$ sudo mv drupal-9.3.7 /var/www/html/drupal

Add permission access and ownership to the Drupal directory:

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

Configure Drupal settings and create its files directory.

$ sudo cp -p /var/www/html/drupal/sites/default/default.settings.php /var/www/html/drupal/sites/default/settings.php
$ sudo mkdir /var/www/html/drupal/sites/default/files

Fix Selinux labels if it is enabled on your system with the following commands.

$ sestatus
$ sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/drupal(/.*)?" 
$ sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/drupal/sites/default/settings.php' 
$ sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/drupal/sites/default/files'  
$ sudo restorecon -Rv /var/www/html/drupal 
$ sudo restorecon -v /var/www/html/drupal/sites/default/settings.php 
$ sudo restorecon -Rv /var/www/html/drupal/sites/default/files 
$ sudo chown -R apache:apache /var/www/html/drupal

Creating Drupal Virtual Host on Apache

Create an Apache virtual host file for Drupal.

$ sudo nano /etc/httpd/conf.d/drupal.conf

Add the following virtual host configuration.

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/drupal/
    ServerName linuxshelltips.lan.network
    ServerAlias www.linuxshelltips.lan.network
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/html/drupal/>
            Options FollowSymLinks
            AllowOverride All
            Require all granted
            RewriteEngine On
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$  index.php?q=$1  [LxQSA]
    </Directory>
</VirtualHost>

Check for syntax errors on the file and restart the apache:

$ sudo apachectl -t
$ sudo systemctl restart httpd

Installing Drupal from Web Browser

Open a web browser and access the domain name you specified in drupal.conf file.

http://linuxshelltips.lan.network
Choose Drupal Language
Choose Drupal Language

Choose language and click continue. On the next screen, go with Standard Profile.

Choose Drupal Installation
Choose Drupal Installation

Next, input the needed database credentials:

Drupal Database Settings
Drupal Database Settings

The above step might take some time to complete, therefore, be patient. Drupal installation should then follow:

Drupal Installation
Drupal Installation

Fill in your site details:

Configure Drupal Website
Configure Drupal Website

Welcome to your new Drupal CMS site:

Running Drupal Website
Running Drupal Website

Your RHEL 8 system is now Drupal-Powered. Best of luck with your CMS projects.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.