Atlantic.Net Blog

How to Install Drupal 9 on Rocky Linux 8

Drupal is a free, flexible, open-source CMS software solution that allows you to build and deploy a website without any coding knowledge. It is written in PHP and uses MySQL/MariaDB as a database backend. Drupal provides a simple and powerful admin interface to manage your content, media, and other assets easier than ever before. It is very similar to other CMS platforms, such as WordPress and Joomla, and helps your organization connect with users, customers, and visitors wherever they are.

In this tutorial, we will show you how to install Drupal 9 CMS with Apache on Rocky Linux 8.

Step 1 – Install Apache and MariaDB Server

First, install the Apache web server and MariaDB database server using the following command:

dnf install httpd mariadb-server curl unzip git -y

Once both packages are installed, start the Apache and MariaDB services and enable them to start at system reboot:

systemctl start httpd
systemctl start mariadb
systemctl enable httpd
systemctl enable mariadb

Step 2 – Install PHP and Other Extensions

Next, it is recommended to install the latest version of PHP and other extensions to your server. By default, the latest version of PHP is not included in the Rocky Linux default repository, so you will need to install it from the Remi repository.

You can install the Remi repository with the following command:

dnf install epel-release -y
dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm

Once installed, reset the default PHP repository and enable the PHP 8.0 repository with the following command:

dnf module reset php
dnf module enable php:remi-8.0

Output:

Last metadata expiration check: 0:00:12 ago on Sunday 08 August 2021 04:13:36 AM UTC.
Dependencies resolved.
===============================================================================================================================================
 Package                           Architecture                     Version                            Repository                         Size
===============================================================================================================================================
Enabling module streams:
 php                                                                remi-8.0                                                                  

Transaction Summary
===============================================================================================================================================

Is this ok [y/N]: y

Next, install the PHP 8 and other extensions using the following command:

dnf install php php-curl php-mbstring php-gd php-xml php-pear php-fpm php-mysql php-pdo php-opcache php-json php-zip php-soap php-xmlrpc -y

Once all the packages are installed, verify the PHP version with the following command:

php -v

Output:

PHP 8.0.9 (cli) (built: Jul 29 2021 12:53:58) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies

Next, edit the php.ini file and tweak some settings:

nano /etc/php.ini

Change the following lines:

memory_limit = 256M
date.timezone = Asia/Kolkata

Save and close the file when you are finished.

Step 3 – Create a Drupal Database

Next, you will need to create a database and user for Drupal. First, connect to the MariaDB with the following command:

mysql

Once you are connected, create a database and user using the following command:

CREATE DATABASE drupaldb;
GRANT ALL ON drupaldb.* TO 'drupaluser'@'localhost' IDENTIFIED BY 'securepassword';

Next, flush the privileges and exit from the MariaDB shell:

FLUSH PRIVILEGES;
EXIT;

Step 4 – Download Drupal

First, download the latest version of Drupal from its official website using the following command:

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

Once the download is completed, extract the downloaded file with the following command:

tar xvf drupal.tar.gz

Next, move the extracted directory to the Apache root directory:

mv drupal-*/  /var/www/html/drupal

Next, create a file directory required for Drupal and copy a sample settings.php file:

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

Next, set proper ownership and permissions on the drupal directory:

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

Step 5 – Configure Apache for Drupal

Next, create an Apache virtual host configuration file for Drupal with the following command:

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

Add the following lines:

<VirtualHost *:80>
     ServerName drupal.example.com
     ServerAdmin [email protected]
     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>

Save and close the file, then restart the Apache service to apply the changes:

systemctl restart httpd

Step 6 – Access Drupal Website

Now Drupal is installed and configured. You can now access it using the URL http://drupal.example.com. You should see the following screen:
Drupal select language
Select your Language and click on Save and continue button. You should see the following screen:
Drupal select installation type
Select an installation type and click on the Save and continue button. You should see the following screen:
Drupal Database Configuration Page
Provide your database information and click on the Save and continue button. You should see the Drupal site information on the following screen:
Drupal Site Configuration Page
Drupal Site Configuration Page
Provide your site information and click on the Save and continue button. Once the installation has been completed, you should see the Drupal dashboard on the following screen:
Drupal Dashboard Page

Conclusion

In the above guide, you learned how to install Drupal with Apache on Rocky Linux 8. You should now have enough knowledge to install Drupal on a live server easily – get started with Drupal on your Atlantic.Net dedicated server.

Get a $250 Credit and Access to Our Free Tier!

Free Tier includes:
G3.2GB Cloud VPS a Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year