‍If you’re looking to build and maintain a powerful website, Drupal is a reliable Content Management System (CMS) that can help you achieve your goals. With its open-source nature and large community, Drupal has become a popular choice for millions of individuals and organizations worldwide. In this comprehensive guide, we will walk you through the step-by-step process of installing Drupal on Alma Linux 9, ensuring a smooth and hassle-free experience. So, let’s get started!

1. Prerequisites

Before we dive into the installation process, let’s make sure we have all the necessary prerequisites in place. Here’s what you’ll need:

  • A server running Alma Linux 9
  • Root access to the server
  • A stable internet connection

Now that we have everything ready, let’s proceed to the next step.

2. Update the System

It’s always a good practice to start by updating the system to ensure that you have the latest packages and security patches. Open your terminal and execute the following command:

dnf update -y

Wait for the update process to complete, and let’s move on to the next step.

3. Install the MariaDB Server

Drupal requires a database to store its content and settings. We will use MariaDB as our database server. To install MariaDB, run the following command:

dnf install mariadb-server mariadb -y

This command will install both the MariaDB server and client packages. Once the installation is complete, proceed to the next step.

4. Enable and Verify MariaDB

After installing the MariaDB server, we need to enable and verify its status. Use the following command to enable MariaDB:

systemctl enable --now mariadb

To verify the status of MariaDB, run the following command:

systemctl status mariadb

Ensure that the output shows the status as “active (running).” If everything looks good, let’s move on to secure our database server.

5. Secure Your Database Server

Securing your database server is crucial to protect your data and prevent unauthorized access. Let’s go through the steps to secure our MariaDB installation.

mysql_secure_installation

You will be prompted to enter the current password for the root user. Since we have just installed MariaDB, the root password will be blank. Press Enter to proceed.

The script will guide you through various security configurations, such as setting a new root password, removing anonymous users, disabling root remote logins, and removing test databases. Follow the prompts and make the appropriate selections based on your requirements.

Once you have completed the security configurations, your MariaDB installation will be secure. Now, let’s create a database for Drupal.

6. Create a Database for Drupal

To create a database for Drupal, we need to log in to the MariaDB server as the root user. Use the following command and enter the root password when prompted:

mysql -u root -p

Once you are logged in, run the following commands to create a new database and a new MySQL user account:

CREATE DATABASE drupal;
GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost' IDENTIFIED BY 'Enter Strong Password here';
FLUSH PRIVILEGES;

Make sure to replace ‘Enter Strong Password here’ with a strong and secure password for your Drupal database user.

Now that we have created the database, let’s proceed to install PHP and its extensions.

7. Install PHP and Extensions

Drupal is built on PHP, so we need to install PHP and a few extensions to ensure compatibility. Run the following commands to install PHP 8.1 and the required extensions:

dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-9.rpm
dnf module enable php:remi-8.1
dnf install php 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 -y

Wait for the installation to complete, and let’s move on to the next step.

8. Confirm PHP Version

After installing PHP, it’s essential to confirm the installed version. Open your terminal and execute the following command:

php -v

The output should display PHP 8.1.x with the corresponding version number. This ensures that PHP is installed correctly and ready to be used by Drupal.

9. Install the Apache Webserver

To serve your Drupal website, we need to install the Apache webserver. Run the following command:

dnf -y install httpd

This command will install the Apache webserver on your Alma Linux 9 server. Once the installation is complete, let’s proceed to the next step.

10. Download and Install Drupal

Now it’s time to download and install Drupal on your server. Run the following commands to download and extract Drupal:

wget https://ftp.drupal.org/files/projects/drupal-10.0.x-dev.tar.gz
tar -xvf drupal-10.0.x-dev.tar.gz
mv drupal-*/ /var/www/html/drupal

These commands will download the latest version of Drupal and extract it into the /var/www/html/drupal directory, which will be our web root for Drupal.

11. Configure Drupal File Permissions

To ensure that Apache can access the necessary files, we need to modify the file permissions. Run the following commands to change ownership and permissions:

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

These commands will change the ownership of the Drupal files to the Apache user and set the appropriate permissions.

12. Configure Apache Web Server for Drupal

To configure the Apache webserver to serve Drupal, we need to create a virtual host file. Run the following command to create the file:

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

Inside the file, paste the following configuration:

<VirtualHost *:80>
ServerName blog.domainhere.info
ServerAlias blog.domainhere.info
ServerAdmin blog.domainhere.info
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]
</Directory>
</VirtualHost>

Make sure to replace blog.domainhere.info with your actual domain name or IP address. Save the file and exit the text editor.

13. Restart Apache Web Server

After making the necessary configuration changes, restart the Apache webserver to apply the changes. Run the following command:

systemctl restart httpd

14. Check and Install Drupal from the Browser

Now that everything is set up, it’s time to check if Drupal is successfully installed. Open your web browser and enter the following URL:

http://blog.domainhere.info

Replace blog.domainhere.info with your actual domain name or IP address. You should see the Drupal installation page.

Follow the on-screen instructions to select an installation profile, set up the database configuration (use the credentials you created earlier), and configure your site. Once you have completed the installation, you’ll be redirected to the Drupal dashboard.

Congratulations! You have successfully installed Drupal on Alma Linux 9. You can now start building your website and leveraging the powerful features of Drupal.

Conclusion

In this comprehensive guide, we have walked you through the step-by-step process of installing Drupal on Alma Linux 9. By following these instructions, you have created a secure and reliable environment for your Drupal website. Remember to regularly update your system, keep your database secure, and stay up-to-date with Drupal’s latest releases and security patches.

If you’re looking for a reliable hosting provider for your Drupal website, consider Shape.host. Shape.host offers high-performance Linux SSD VPS hosting solutions, ensuring fast and secure hosting for your Drupal site. With their scalable infrastructure and expert support, you can focus on building and growing your online presence.