How to Install Drupal on Alma Linux 9

Drupal is a Content Management System (CMS) to maintain and publish an internet website. Drupal is an open-source content management system (CMS) with a large, supportive community used by millions of people and organizations around the globe to build and maintain their websites.

Update the system.

dnf update -y 

Install the MariaDB Server

Install the MariaDB Server by running the following command,

dnf install mariadb-server mariadb


[root@server ~]# dnf install mariadb-server mariadb
AlmaLinux 9 - AppStream                         8.6 MB/s | 6.5 MB     00:00
AlmaLinux 9 - BaseOS                            3.3 MB/s | 1.9 MB     00:00
AlmaLinux 9 - Extras                             20 kB/s |  11 kB     00:00
Dependencies resolved.
 Package                       Arch    Version                 Repository  Size
 mariadb                       x86_64  3:10.5.13-2.el9         appstream  1.6 M
 mariadb-server                x86_64  3:10.5.13-2.el9         appstream  9.3 M
Installing dependencies:
 checkpolicy                   x86_64  3.3-1.el9               appstream  339 k
 libaio                        x86_64  0.3.111-13.el9          baseos      23 k
 mariadb-common                x86_64  3:10.5.13-2.el9         appstream   32 k

Enable MariaDB using the below command,

systemctl enable --now mariadb

Verify the status of MariaDB using the below command.

systemctl status mariadb 


[root@server ~]#     systemctl status mariadb
● mariadb.service - MariaDB 10.5 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor p>
     Active: active (running) since Thu 2022-06-02 15:26:40 CEST; 5s ago
       Docs: man:mariadbd(8)
    Process: 31603 ExecStartPre=/usr/libexec/mariadb-check-socket (code=exited,>
    Process: 31625 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir mariadb.ser>
    Process: 31717 ExecStartPost=/usr/libexec/mariadb-check-upgrade (code=exite>
   Main PID: 31705 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 11 (limit: 5912)
     Memory: 75.8M
        CPU: 546ms
     CGroup: /system.slice/mariadb.service
             └─31705 /usr/libexec/mariadbd --basedir=/usr

Secure your database server by setting the root password, disabling root remote logins, and removing test databases.



[root@server ~]# mysql_secure_installation    


In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] 
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Create Database for Drupal

mysql -u root -p

First, we'll create a new database


Next, create a new MySQL user account that we will use to operate on Drupal new database, with the username "drupal"

GRANT ALL PRIVILEGES ON drupal.* TO ‘drupal’@’localhost’ IDENTIFIED BY '<Enter Strong Password here>'

Flush the privileges so that MySQL knows about the user permissions we just added,


Exit out of the MySQL command prompt by typing,


The above commands will give complete access to the drupal Database to the user drupal. We would suggest using a strong and long password.


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

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 drupal;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON drupal.* TO ‘drupal’@’localhost’ IDENTIFIED BY "Enter Strong Password here";
Query OK, 0 rows affected (0.001 sec)

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

MariaDB [(none)]>     \q

Install PHP and Extensions

Install PHP 8.1 as the default version then use the commands below,

dnf install
dnf install dnf-utils
dnf module enable php:remi-8.1
dnf install php
dnf install php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imap php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml 

Confirm PHP version,

php -v 


[root@server ~]# php -v
PHP 8.1.6 (cli) (built: May 11 2022 01:14:18) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.6, Copyright (c), by Zend Technologies
[root@server ~]#

Start php-fpm service on your server using the below command,

systemctl enable php-fpm
systemctl start php-fpm

Install Apache Webserver

Install the Apache Webserver by running the following command,

dnf -y install httpd


[root@server ~]# dnf -y install httpd
Last metadata expiration check: 0:08:22 ago on Thu Jun  2 15:24:49 2022.
Dependencies resolved.
 Package                   Arch       Version               Repository     Size
 httpd                     x86_64     2.4.51-7.el9_0        appstream     1.4 M
Installing dependencies:
 almalinux-logos-httpd     noarch     90.5.1-1.el9          appstream      18 k
 apr                       x86_64     1.7.0-11.el9          appstream     123 k
 apr-util                  x86_64     1.6.1-20.el9          appstream      95 k
 apr-util-bdb              x86_64     1.6.1-20.el9          appstream      13 k
 httpd-filesystem          noarch     2.4.51-7.el9_0        appstream      14 k
 httpd-tools               x86_64     2.4.51-7.el9_0        appstream      81 k
 mailcap                   noarch     2.1.49-5.el9          baseos         32 k

Set PHP Memory limit,

vi /etc/php.ini
memory_limit = 256M

Start PHP and httpd services,

systemctl enable --now httpd php-fpm

If firewalld service running open port for 80,

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

Download and Install Drupal

Download and install Drupal by running the following command,

dnf install -y wget 

Extract the downloaded file,

dnf install tar
tar xvf drupal-10.0.x-dev.tar.gz
mv drupal-*/  /var/www/html/drupal

Modify the file permissions to allow Apache to access the files inside /var/www/html/drupal directory,

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

Create additional files for a drupal installer,

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

If SELinux is Enabled then Fix SELinux labels,

dnf install policycoreutils-python-utils
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/drupal(/.*)?"
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/drupal/sites/default/settings.php'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/drupal/sites/default/files'
restorecon -Rv /var/www/html/drupal
restorecon -v /var/www/html/drupal/sites/default/settings.php
restorecon -Rv /var/www/html/drupal/sites/default/files
chown -R apache:apache  /var/www/html/drupal

Configure Apache Web Server for Drupal.

Configure Drupal VirtualHost file /etc/httpd/conf.d/drupal.conf

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

Copy the below content and save it into the file.

Replace with your actual domain name.

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

     <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]

Restart Apache web server,

systemctl restart httpd

Check and Install Drupal on Alma Linux 9 from the browser.

Access the Drupal configuration page by using

Replace with your actual domain.


Select an installation profile.


Set Database Configure for Drupal.


Configure your site,


You’ll get to the Drupal dashboard in a few,