How to Install Drupal on AlmaLinux, Rocky Linux, Debian, and Ubuntu

Drupal is an open-source content management system that allows you to create powerful websites. In this guide, we'll show you how to install Drupal on AlmaLinux, Rocky Linux, Debian, and Ubuntu. The installation process is simple and can be done in a few steps.


Prerequisites:

Before starting the installation, make sure you have the following:

  • A server running AlmaLinux, Rocky Linux, Debian, or Ubuntu.
  • Root or sudo access to your server.
  • A LAMP stack installed (Linux, Apache, MySQL/MariaDB, PHP).
  • A domain or subdomain pointing to your server.

Step 1: Update the System

Start by ensuring that your server's packages are up-to-date:

  • On Ubuntu/Debian:

     
    sudo apt update && sudo apt upgrade -y
  • On AlmaLinux/Rocky Linux:

     
    sudo dnf update -y

Step 2: Install Required Software

You will need Apache, MySQL/MariaDB, and PHP to run Drupal.

  • For Ubuntu/Debian:

     
    sudo apt install apache2 mariadb-server php libapache2-mod-php php-mysql php-xml php-cli php-gd php-mbstring php-json unzip wget -y
  • For AlmaLinux/Rocky Linux:

     
    sudo dnf install httpd mariadb-server php php-mysqlnd php-xml php-cli php-gd php-mbstring php-json unzip wget -y

Step 3: Configure the Database

Now, create a MySQL or MariaDB database for Drupal.

  1. Log in to MariaDB:

     
    sudo mysql -u root -p
  2. Create the database and user:

    sql
     
    CREATE DATABASE drupal_db; CREATE USER 'drupal_user'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON drupal_db.* TO 'drupal_user'@'localhost'; FLUSH PRIVILEGES; EXIT;

Step 4: Download and Extract Drupal

  1. Download the latest version of Drupal:

    Visit the Drupal download page to get the latest version, or use the following command to download it:

     
    wget https://www.drupal.org/download-latest/tar.gz
  2. Extract Drupal:

     
    tar -xzvf drupal-*.tar.gz -C /var/www/html/
  3. Set proper permissions:

     
    sudo chown -R www-data:www-data /var/www/html/drupal # For Ubuntu/Debian sudo chown -R apache:apache /var/www/html/drupal # For AlmaLinux/Rocky Linux

Step 5: Configure Apache (for AlmaLinux/Rocky Linux)

  1. Create a new virtual host configuration:

     
    sudo nano /etc/httpd/conf.d/drupal.conf
  2. Add the following configuration:

     
    <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/html/drupal ServerName yourdomain.com ErrorLog /var/log/httpd/error_log CustomLog /var/log/httpd/access_log combined </VirtualHost>
  3. Restart Apache:

     
    sudo systemctl restart httpd

Step 6: Configure Apache (for Ubuntu/Debian)

  1. Create a new virtual host configuration:

     
    sudo nano /etc/apache2/sites-available/drupal.conf
  2. Add the following content:

     
    <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/html/drupal ServerName yourdomain.com ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
  3. Enable the site and restart Apache:

     
    sudo a2ensite drupal.conf sudo systemctl restart apache2

Step 7: Complete the Web Installation

  1. Open your browser and navigate to your server's IP address or domain name (e.g., http://yourdomain.com).

  2. The Drupal installation page will appear. Choose your language and click Save and Continue.

  3. Enter the database information:

    • Database type: MySQL, MariaDB
    • Database name: drupal_db
    • Database username: drupal_user
    • Database password: your_password
  4. Complete the installation process by following the instructions on the screen.


Step 8: Clean Up

  1. Remove the installation folder for security:

     
    sudo rm -rf /var/www/html/drupal/install.php
  2. Set proper permissions for your Drupal installation:

     
    sudo chmod -R 755 /var/www/html/drupal

Conclusion

You have successfully installed Drupal on your AlmaLinux, Rocky Linux, Debian, or Ubuntu server. You can now log in to your Drupal website’s admin panel to start building your site.

Was this answer helpful? 0 Users Found This Useful (0 Votes)

Powered by WHMCompleteSolution