How to Install Drupal on AlmaLinux 9

install drupal on almalinux 9

In this tutorial, we will explain in detail how to install Drupal on AlmaLinux 9 OS.

Drupal is an open-source Content Management System (CMS) written in PHP and used worldwide in over 10 thousand top-rated websites.

Its core supports a variety of modules, themes, languages, and features that can be easily enabled in the Drupal dashboard. In this blog post, we will install Drupal with the LAMP stack.

Installing Drupal on AlmaLinux 9 is straightforward and may take up to 15 minutes. Let’s get things done!

Prerequisites

  • A server with AlmaLinux 9 as OS
  • Valid domain pointed to the servers IP address
  • User privileges: root or non-root user with sudo privileges

Step 1. Update the System

Before we start with the installation of the LAMP stack, we will update the system packages to their latest version available.

sudo dnf update -y && sudo dnf upgrade -y

Step 2. Install LAMP stack

First, we will install the Apache web server. Execute the following command:

sudo dnf install httpd -y

Once installed, start and enable the service.

sudo systemctl enable httpd && sudo systemctl start httpd

Check if the service is up and running:

sudo systemctl status httpd

You should receive the following output:

[root@host ~]# sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
    Drop-In: /usr/lib/systemd/system/httpd.service.d
             └─php-fpm.conf
     Active: active (running) since Wed 2023-03-08 18:47:07 CST; 1 day 21h ago
       Docs: man:httpd.service(8)
   Main PID: 565 (httpd)
     Status: "Total requests: 244; Idle/Busy workers 100/0;Requests/sec: 0.0015; Bytes served/sec:   3 B/sec"
      Tasks: 278 (limit: 24796)
     Memory: 45.7M
        CPU: 2min 47.518s
     CGroup: /system.slice/httpd.service

Then we will install PHP8 with its extensions. Execute the following command to install the PHP8:

sudo dnf install php php-cli php-fpm php-curl php-mysqlnd php-gd php-readline php-mbstring php-apcu php-xml php-dom php-opcache php-zip php-intl php-common php-bcmath php-json -y

Once installed, check the installed PHP version. Execute the php -v on the command line. You should receive the following output:

[root@host ~]# php -v
PHP 8.0.27 (cli) (built: Jan  3 2023 16:17:26) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.27, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.27, Copyright (c), by Zend Technologies

The last installation of the LAMP stack is the MySQL service. To install the MySQL server execute the following command:

sudo dnf install mysql-server mysql -y

Start and enable the mysqld.service with the following commands:

sudo systemctl start mysqld && sudo systemctl enable mysqld

Check the status of the mysqld.service

sudo systemctl status mysqld

You should receive the following output:

[root@host ~]# sudo systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
     Active: active (running) since Fri 2023-03-10 16:00:59 CST; 39s ago
   Main PID: 7539 (mysqld)
     Status: "Server is operational"
      Tasks: 39 (limit: 24796)
     Memory: 454.4M
        CPU: 9.763s
     CGroup: /system.slice/mysqld.service
             └─7539 /usr/libexec/mysqld --basedir=/usr

Mar 10 16:00:46 host.test.vps systemd[1]: Starting MySQL 8.0 database server...
Mar 10 16:00:46 host.test.vps mysql-prepare-db-dir[7457]: Initializing MySQL database
Mar 10 16:00:59 host.test.vps systemd[1]: Started MySQL 8.0 database server.

Step 3. Create a Drupal Database and User

To create a MySQL database, database user and grant permissions to that user, log in to MySQL with the mysql command in your console and execute the commands below:

CREATE DATABASE drupal;
CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'YourStrongPasswordHere';
GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost';
FLUSH PRIVILEGES;
exit;

Step 4. Install Drupal

Before we install Drupal, we first need to download it in the default Apache document root:

cd /var/www/html

wget https://ftp.drupal.org/files/projects/drupal-9.3.16.zip

unzip drupal-9.3.16.zip

mv drupal-9.3.16/ drupal/

Set the right permissions to files and folders.

chown -R apache:apache drupal/

find . -type d -exec chmod 755 {} \;

find . -type f -exec chmod 644 {} \;

Step 5. Create Apache Virtual Host File

We need to create an Apache virtual host configuration file in order can access Drupal via the domain name:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
sudo nano /etc/httpd/conf.d/drupal.conf

Paste the following lines of code:

<VirtualHost *:80>
     ServerName yourdomain.com
     DocumentRoot /var/www/html/drupal
     <Directory /var/www/html/drupal/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>

     ErrorLog /var/log/httpd/yourdomain.com_error.log
     CustomLog /var/log/httpd/yourdomain.com.log combined
</VirtualHost>

Save the file, close it check the syntax of the Apache configuration file.

httpd -t

You should get this output:

[root@host project]# httpd -t
Syntax OK

Restart the httpd.service.

sudo systemctl restart httpd

Now you can access Drupal at http://yourdomain.com to finish the installation. You can choose different options while finishing the installation. Everything that is necessary for database information is in the previous Step 3.

That’s it. You successfully installed Drupal CMS on AlmaLinux 9. If you find any difficulties with installing Drupal, you can always contact our technical support. All you have to do is to sign up for one of our NVMe VPS plans and submit a support ticket. We are available 24/7

If you liked this about installing Drupal on AlmaLinux 9, please share it with your friends on social networks or simply leave a reply below.

Leave a Comment