Drupal is a powerful open-source content management system (CMS) used for building robust and scalable websites. This guide will walk you through installing Drupal on Ubuntu, Debian, AlmaLinux, and Rocky Linux.
Prerequisites
Before installing Drupal, ensure you have the following:
-
A server running Ubuntu 22.04/20.04, Debian 11/10, AlmaLinux 9/8, or Rocky Linux 9/8.
-
Root or sudo access.
-
A LAMP (Linux, Apache, MySQL/MariaDB, PHP) stack installed.
-
At least 2GB of RAM and 2 CPUs.
Step 1: Update Your System
Update your package lists and upgrade installed packages:
sudo apt update && sudo apt upgrade -y # For Ubuntu/Debian
sudo dnf update -y # For AlmaLinux/Rocky
Step 2: Install Required Packages
Install Apache, MariaDB (MySQL), PHP, and required extensions:
# For Ubuntu/Debian
sudo apt install apache2 mariadb-server php php-cli php-mbstring php-xml php-curl php-gd php-zip unzip wget -y
# For AlmaLinux/Rocky
sudo dnf install httpd mariadb-server php php-cli php-mbstring php-xml php-curl php-gd php-zip unzip wget -y
Start and enable services:
sudo systemctl enable --now apache2 mariadb # Ubuntu/Debian
sudo systemctl enable --now httpd mariadb # AlmaLinux/Rocky
Step 3: Configure MariaDB Database
Secure your database and create a new database for Drupal:
sudo mysql_secure_installation
Log into MariaDB and create the database:
sudo mysql -u root -p
CREATE DATABASE drupal;
CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'secure_password';
GRANT ALL PRIVILEGES ON drupal.* TO 'drupaluser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 4: Download and Install Drupal
Navigate to the web root and download the latest Drupal version:
cd /var/www/html
wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
sudo tar -xvzf drupal.tar.gz
sudo mv drupal-* drupal
Set the correct permissions:
sudo chown -R www-data:www-data /var/www/html/drupal
sudo chmod -R 755 /var/www/html/drupal
Step 5: Configure Apache
Create a new virtual host file:
sudo nano /etc/apache2/sites-available/drupal.conf # Ubuntu/Debian
sudo nano /etc/httpd/conf.d/drupal.conf # AlmaLinux/Rocky
Add the following content:
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/drupal
ServerName your-domain.com
<Directory /var/www/html/drupal>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the site and restart Apache:
sudo a2ensite drupal.conf # Ubuntu/Debian
sudo systemctl restart apache2 # Ubuntu/Debian
sudo systemctl restart httpd # AlmaLinux/Rocky
Step 6: Finalize Drupal Installation
-
Open your browser and visit
http://your-domain.com
. -
Follow the on-screen installation wizard.
-
Enter the database credentials created earlier.
-
Configure the site name and admin account.
-
Complete the setup and remove the installation files:
sudo rm -rf /var/www/html/drupal/core/install.php
Conclusion
You have successfully installed Drupal on Ubuntu, Debian, AlmaLinux, or Rocky Linux. Your CMS is now ready for content creation and customization. To enhance security, enable SSL with Let’s Encrypt and configure a firewall.