FedoraRHEL Based

How To Install Drupal on Fedora 41

Install Drupal on Fedora 41

Drupal, a powerful and versatile content management system (CMS), has long been a favorite among web developers and content creators. Its robust features and flexibility make it an excellent choice for building websites of all sizes. In this comprehensive guide, we’ll walk you through the process of installing Drupal on Fedora 41, the latest release of the popular Linux distribution.

Fedora 41, known for its cutting-edge software and strong focus on security, provides an ideal environment for hosting Drupal. By combining these two technologies, you’ll create a solid foundation for your web projects. Whether you’re a seasoned developer or a newcomer to the world of content management systems, this step-by-step tutorial will help you get Drupal up and running on your Fedora 41 system.

1. Prerequisites

Before diving into the installation process, it’s crucial to ensure your system meets the necessary requirements. This preparation will help avoid potential roadblocks and ensure a smooth installation experience.

System Requirements

To run Drupal effectively on Fedora 41, your system should meet or exceed the following specifications:

  • A 64-bit processor (x86_64)
  • At least 2 GB of RAM (4 GB or more recommended for optimal performance)
  • 20 GB of free disk space (more if you plan to host large media files)
  • A stable internet connection for downloading packages and updates

Software Requirements

Drupal relies on several key software components to function properly. Fedora 41 makes it easy to install these dependencies:

  • Apache web server
  • MariaDB (or MySQL) database server
  • PHP 8.1 or higher
  • Various PHP extensions (we’ll cover these in detail later)

Basic Knowledge

While this guide aims to be as comprehensive as possible, having a basic understanding of the following will be beneficial:

  • Linux command-line interface (CLI) usage
  • Basic system administration concepts
  • Familiarity with text editors like nano or vim

2. Setting Up Your Fedora 41 Environment

With the prerequisites in mind, let’s begin by preparing your Fedora 41 system for Drupal installation.

Updating the System

First, ensure your system is up to date. Open a terminal and run the following command:

sudo dnf update

This command will fetch the latest package information and install any available updates. It’s a good practice to keep your system updated to ensure security and stability.

Installing Required Packages

Next, we’ll install the necessary software packages. Fedora conveniently groups related packages, making installation straightforward:

sudo dnf groupinstall "Web Server" "MySQL Database"
sudo dnf install drupal php php-mysqlnd php-opcache php-gd php-xml php-mbstring php-json

These commands install Apache, MariaDB, PHP, and several PHP extensions required by Drupal. The additional PHP extensions (gd, xml, mbstring, json) are crucial for Drupal’s functionality and are often overlooked in basic setups.

Starting and Enabling Services

With the software installed, we need to start and enable the Apache and MariaDB services:

sudo systemctl enable httpd mariadb
sudo systemctl start httpd mariadb

These commands ensure that Apache and MariaDB start automatically when your system boots and are currently running.

3. Configuring the Database

A properly configured database is crucial for Drupal’s operation. Let’s set up MariaDB to host our Drupal database.

Securing MariaDB Installation

First, we’ll secure the MariaDB installation:

sudo mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disallow root login remotely, and remove the test database. These steps significantly enhance your database security.

Creating a Database for Drupal

Now, let’s create a database and user for Drupal. Access the MariaDB shell:

mysql -u root -p

Enter the root password you set earlier. Then, execute the following SQL commands:

CREATE DATABASE drupal;
CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'choose_a_strong_password';
GRANT ALL PRIVILEGES ON drupal.* TO 'drupaluser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace ‘choose_a_strong_password‘ with a secure password of your choice. This creates a database named ‘drupal‘ and a user ‘drupaluser’ with full privileges on that database.

4. Downloading and Installing Drupal

With our environment prepared and database configured, we’re ready to download and set up Drupal.

Downloading Drupal

First, navigate to your home directory and download the latest version of Drupal:

cd ~
wget https://www.drupal.org/download-latest/tar.gz
tar -xvzf tar.gz

This downloads the Drupal archive and extracts its contents.

Setting Up Directory Structure

Move the extracted Drupal files to the web server’s document root:

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

This command places Drupal in a subdirectory of the default Apache document root.

Setting Permissions

Proper file permissions are crucial for security and functionality. Set the correct ownership and permissions:

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

These commands ensure that the Apache web server can read and execute the Drupal files, while maintaining security.

5. Configuring Apache for Drupal

Now, let’s configure Apache to serve our Drupal installation.

Creating Apache Configuration File

Create a new configuration file for Drupal:

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

Sample Configuration Content

Add the following content to the file:

<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    DocumentRoot /var/www/html/drupal
    ServerName example.com
    ServerAlias www.example.com

    <Directory /var/www/html/drupal>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog /var/log/httpd/drupal_error.log
    CustomLog /var/log/httpd/drupal_access.log combined
</VirtualHost>

Replace ‘example.com‘ with your domain name. This configuration tells Apache where to find your Drupal files and how to handle requests.

Enabling URL Rewriting

Drupal uses URL rewriting for clean URLs. Enable the rewrite module:

sudo sed -i 's/#LoadModule rewrite_module modules\/mod_rewrite.so/LoadModule rewrite_module modules\/mod_rewrite.so/' /etc/httpd/conf.modules.d/00-base.conf
sudo systemctl restart httpd

This command uncomments the rewrite module in Apache’s configuration and restarts the service to apply changes.

6. Finalizing the Installation via Web Interface

With all the backend setup complete, we can now finish the installation through Drupal’s web interface.

Accessing the Drupal Installer

Open a web browser and navigate to http://your_server_ip/drupal or http://your_domain/drupal. You should see the Drupal installation page.

Installation Steps Overview

  1. Choose your preferred language.
  2. Select an installation profile (Standard is recommended for most users).
  3. Configure the database:
    • Database name: drupal
    • Database username: drupaluser
    • Database password: (the password you set earlier)
    • Host: localhost
  4. Wait for Drupal to install.

Install Drupal on Fedora 41

Post-installation Configuration

After the installation completes, you’ll be prompted to configure your site:

  • Set up the site name
  • Create an admin account
  • Configure regional settings
  • Choose update notification settings

Take your time to configure these settings according to your needs. Remember, you can always change them later through the Drupal admin interface.

7. Securing Your Drupal Installation

Security should always be a top priority. Let’s take some additional steps to secure your Drupal installation.

Changing Permissions on settings.php

Restrict access to the settings.php file:

sudo chmod 644 /var/www/html/drupal/sites/default/settings.php

This prevents unauthorized modifications to your Drupal configuration.

Configuring Firewall Settings

Allow HTTP traffic through the firewall:

sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload

These commands open port 80 for web traffic while maintaining your system’s security.

8. Troubleshooting Common Issues

Even with careful preparation, you might encounter some issues. Here are solutions to common problems:

Common Installation Problems

  • White screen of death: Often caused by PHP memory limits. Increase the memory limit in php.ini.
  • Database connection errors: Double-check your database credentials in settings.php.
  • Missing PHP extensions: Install any missing extensions using dnf.

SELinux Configuration Adjustments

If you’re experiencing permission issues, SELinux might be the culprit. Try this command:

sudo setsebool -P httpd_can_network_connect_db 1

This allows Apache to connect to databases, which is necessary for Drupal.

Database Connection Errors

If you’re having trouble connecting to the database, ensure MariaDB is running:

sudo systemctl status mariadb

If it’s not running, start it with:

sudo systemctl start mariadb
Congratulations! You have successfully installed Drupal. Thanks for using this tutorial for installing Drupal CMS on your Fedora 41 system. For additional help or useful information, we recommend you check the official Drupal website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button