Thursday, July 18, 2024
HomeHow toHow to Install Drupal on Alma Linux 9

How to Install Drupal on Alma Linux 9

Drupal is an open-source content management system (CMS) used for building and managing websites. Known for its flexibility and robustness, Drupal allows users to create and organize content, customize the presentation, automate administrative tasks, and manage user roles and permissions. It is particularly favored for its modular architecture, which enables developers to extend and modify functionalities through thousands of add-on modules and themes. Drupal is highly scalable, making it suitable for small personal blogs as well as large enterprise and government websites. Its strong community support and comprehensive documentation further enhance its usability and development potential.

In this tutorial, we’ll guide you through the installation of Drupal on an Alma Linux 9 server using the LAMP stack (Linux, Apache/Httpd, MariaDB, and PHP). After that, we’ll demonstrate how to secure your Drupal installation with Firewalld and SSL certificates using Certbot and Let’s Encrypt.


Before you start, make sure you have the following requirements:

  • An Alma Linux 9 server.
  • A non-root user with administrator privileges.
  • A domain name pointed to a server IP address.
  • A SELinux with status permissive.

Installing Dependencies

At this time, Drupal’s latest version requires PHP 8.3, so you need to install it via a third-party repository. Also, you will install other dependencies including the Httpd web server and MariaDB server.

Before installing dependencies, add the EPEL and Remi repository to your Alma Linux server. Input y when prompted to add the repository.

sudo dnf install epel-release dnf-utils

In RHEL-based distributions, some packages come as repository modules. Enable the repository module for PHP 8.3 via the Remi repository with the command below.

sudo dnf module reset php
sudo dnf module enable php:remi-8.3

Now install the LAMP Stack (Apache/Httpd, MariaDB, and PHP) packages with the dnf command below. When prompted, enter y to confirm the installation.

sudo dnf install httpd mariadb-server php php-cli php-devel php-mbstring php-gd php-xml php-curl php-mysqlnd php-pdo php-json php-opcache php-pear php-pecl-apcu php-pecl-crypto

After installation is completed, start and enable the httpd service using the command below.

sudo systemctl start httpd
sudo systemctl enable httpd

Then start and enable the mariadb service with the command below.

sudo systemctl start mariadb
sudo systemctl enable mariadb

Lastly, verify the PHP version using the following command. You will see PHP 8.3 installed on your system.

php -v
php -m

Setting up Firewalld

By default, the firewalld is up and running on Alma Linux. You must open access to HTTP and HTTPS protocols via firewalld and allow traffic to your Drupal installation.

Add both HTTP and HTTPS service to firewalld using the command below. Then, reload firewalld to apply the changes.

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

Now run the command below to verify the firewalld status and list enabled rules. You will see both HTTP and HTTPS services added to the firewalld.

sudo firewall-cmd --list-all

Setting up PHP

In this section, you will set up PHP by editing the default configuration /etc/php.ini and installing additional extension uploadprogress via PECL (PHP Extension Community Library). The upload progress extension is needed by Drupal but is only available as a PECL package.

Open the PHP config file /etc/php.ini using the nano editor command below.

sudo nano /etc/php.ini

Change the default configuration with the following. Make sure to adjust the memory_limit and date.timezone options with your current environment.

memory_limit = 512M
upload_max_filesize = 60M
max_execution_time = 300
date.timezone = Europe/Stockholm

Save and exit the file after finished.

Now run the command below to install the uploadprogress module to your system. The uploadpprogress module is available on the PECL repository, not in the package repository.

sudo pecl install uploadprogress

Once the installation is complete, you will get the following output:

Next, run the following command to create a new configuration for enabling the uploadprogress extension.

cat <; configuration for php uploadprogress module
; priority 15

Restart the httpd service to apply modifications to PHP.

sudo systemctl restart httpd

Lastly, verify module uploadprogress with the command below. Make sure the uploadprogress module is enabled on your PHP installation.

php -m | grep uploadprogress

Setting up MariaDB

After configuring PHP, you will need to configure your MariaDB server installation. You will secure MariaDB via the command line, then create a new database and user for Drupal via the MariaDB client.

Secure your MariaDB server with the command below.

sudo mariadb-secure-installation

During the process, input Y to confirm and apply a new configuration or N to reject the configuration. Below are the MariaDB configurations that will be asked for:

  • Switch to unix_socket authentication?. Input n and press ENTER. The default MariaDB root user is already protected. optionally, you can also enable it by typing y for yes.
  • Change the root password?. Input y to confirm and set up your new MariaDB root password.
  • Remove anonymous user?. Input y to confirm.
  • Disallow root login remotely? Input y to confirm. Only local connection will be allowed if you are using the MariaDB root user.
  • Remove the test database and access to it?. Input y to confirm and remove the default database ‘test’.
  • Lastly, input y again to reload all tables privileges on your MariaDB server and apply new changes.

Log in to the MariaDB server with the mariadb command below. Type your MariaDB root password when prompted.

sudo mariadb -u root -p

Now run the following queries to create a new database drupaldb, a user drupal, with the password p4ssword. This database will be used by Drupal, so make sure to adjust the following database details with your information.

CREATE USER drupal@localhost IDENTIFIED BY 'p4ssword';
GRANT ALL ON drupaldb.* TO drupal@localhost WITH GRANT OPTION;

Next, verify privileges for the user Drupal using the query below. You will see user Drupal can access the database Drupaldb.

SHOW GRANTS FOR drupal@localhost;

Lastly, enter quit to exit from the MariaDB server.

Downloading Drupal Source Code

Now that you have configured MariaDB and created the database and user, you can download the Drupal source code and configure the DocuemtRoot or web root directory for Drupal installation. In this case, you will download the Drupal source code via wget instead of installing it via Composer.

Go to the /var/www directory and download the latest Drupal source code using the wget command below.

cd /var/www/
wget -O drupal.tar.gz

once downloaded, extract the Drupal source code and rename the extracted directory to drupal. With this, your DocumentRoot directory for Drupal will be available at /var/www/drupal

tar -xvf drupal.tar.gz
mv drupal-* drupal

Now run the command below to change the ownership of the/var/www/drupal directory to the apache user and change the permission to 755.

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

Creating Httpd Virtual Host

In this section, you will create a new Httpd virtual host configuration for Drupal. So make sure you have prepared your domain name for Drupal, whether local or public domain name.

First, create a new httpd virtual host configuration /etc/httpd/conf.d/drupal.conf using the following nano editor command.

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

Insert the configuration below and be sure to change the ServerName option with your domain name.

ServerName howtoforge.local
ServerAdmin [email protected]
DocumentRoot /var/www/drupal

ErrorLog /var/log/httpd/howtoforge.local.error.log
CustomLog /var/log/httpd/howtoforge.local.access.log combined

Options FollowSymlinks
#Allow .htaccess
AllowOverride All
Require all granted

SecRuleEngine Off
# or disable only problematic rules

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Save the file and exit the editor after it is finished.

Now run the command below to verify your httpd configuration. Ensure you have an output Syntax OK, confirming that you have proper httpd syntax.

sudo apachectl configtest

Lastly, restart the httpd with the command below to apply your new virtual host changes.

sudo systemctl restart httpd

Setting up HTTPS via Certbot

In this section, you will configure HTTPS for Drupal via Certbot and Letsencrypt. Do this when you’re using the public domain, for the local domain, you can generate a Self-signed certificate.

Install the Certbot and Certbot Apache plugin using the command below. Enter y to confirm the installation.

sudo dnf install certbot python3-certbot-apache

After installation is complete, generate SSL/TLS certificates for your Drupal installation using the certbot command below. Make sure to change the domain name and email address with your information.

sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d howtoforge.local

Once the process is complete, your SSL/TLS certificates will be available in/etc/letsencrypt/live/ directory. Also, your Drupal installation should automatically configured with HTTPS.

Installing Drupal

Open your web browser and visit the Drupal installation domain name such as https://howtoforge.local/.

Select your preferred language and click Save and continue button.

For the installation profile, select Standard if you’re first time installing Drupal, then click Save and continue.

After the system check is complete, you will see the database configuration for Drupal. Input details of your MariaDB database information, click Save and continue again.

Now, the Drupal installation should start, and you will see the following:

Once the installation is complete, input details of your Drupal site information and create a new admin user for Drupal. Then, click Save and continue to confirm.

When the configuration is finished, you will get the Drupal homepage like the following:


Congratulations! You have now installed Drupal on the Alma Linux 9 server. You have installed Drupal with Httpd, MariaDB, and PHP. Also secured Drupal with SSL/TLS from Letsencrypt. With Drupal installed, start adding new themes or install Extensions.



Please enter your comment!
Please enter your name here

Most Popular