How to Install Drupal CMS 11 on Ubuntu

By Anurag Singh

Updated on Sep 23, 2024

How to Install Drupal CMS 11 on Ubuntu

Tutorial will explain how to install Drupal CMS 11 on Ubuntu 24.04 with Nginx, MariaDB and SSL.

Drupal is a powerful open-source content management system (CMS) used for building websites and applications. It is known for its flexibility, scalability, and robust features, making it suitable for a wide range of projects, from simple blogs to complex enterprise applications. Here’s an overview of Drupal, its features, and its ecosystem.

Key Features of Drupal

Flexibility and Customization:

  • Content Types: Drupal allows you to create different content types (e.g., articles, pages, blogs) with custom fields tailored to your needs.
  • Taxonomy: Use taxonomy systems to categorize and tag content, making it easier to manage and display.

Modular Architecture:

  • Drupal has a modular structure, allowing you to extend its functionality through contributed and custom modules. There are thousands of modules available, enabling features like SEO, social media integration, e-commerce, and more.

User Management:

  • Built-in user management allows you to create and manage user roles and permissions. This is ideal for collaborative environments where different users need varying levels of access.

Responsive Design:

  • Many Drupal themes are designed to be responsive out of the box, ensuring that websites look good on all devices, from desktops to mobile phones.

Robust Security:

  • Drupal has a strong focus on security, with a dedicated security team and regular updates. It also allows for granular permissions, helping to secure sensitive content.

Multilingual Support:

  • Drupal offers excellent support for multilingual websites, allowing you to create content in multiple languages and manage translations efficiently.

SEO-Friendly:

  • Drupal provides various tools and modules that help optimize your site for search engines, including clean URLs, metadata management, and XML sitemaps.

Community and Support:

  • Drupal has a large and active community of developers, designers, and users who contribute to its development and provide support through forums, documentation, and events.

This tutorial will guide you through deploying Drupal on an Ubuntu server using Nginx as the web server and MariaDB as the database backend.

Prerequisites

  • A server running Ubuntu 24.04 dedicated server or KVM VPS.
  • A root or non-root user with sudo privileges.
  • A domain name pointing to your server’s IP address.
  • Basic knowledge of the command line and Linux administration.

How to Deploy Drupal CMS on Ubuntu

Step 1: Update and Upgrade the System

Begin by updating your server’s package index and upgrading installed packages to the latest version.

sudo apt update && sudo apt upgrade -y

Step 2: Install Nginx Web Server

Nginx will serve as the web server for Drupal.

Install Nginx:

sudo apt install nginx -y

Enable Nginx to start on boot and start the service:

sudo systemctl enable nginx
sudo systemctl start nginx

Check the status of Nginx to ensure it’s running:

sudo systemctl status nginx

Step 3: Install PHP and Required Extensions

Drupal requires PHP and several extensions. Install PHP and the necessary extensions as follows:

sudo apt install php-fpm php-mysql php-gd php-xml php-mbstring php-curl php-zip php-json -y

Step 4: Install MariaDB and Secure the Installation

MariaDB will be used as the database server for Drupal.

Install MariaDB:

sudo apt install mariadb-server -y

Secure the MariaDB installation by running the security script:

sudo mysql_secure_installation

Follow the prompts to set the root password, remove anonymous users, disallow remote root login, remove the test database, and reload the privilege tables.

Step 5: Create a Database and User for Drupal

Log into MariaDB as the root user:

sudo mysql -u root -p

Create a new database for Drupal (replace drupal_db with your preferred database name):

CREATE DATABASE drupal_db CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Create a new MariaDB user and grant all privileges on the Drupal database (replace drupal_user and password with your desired username and strong password):

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

Step 6: Download and Configure Drupal

Navigate to the web root directory:

cd /var/www/

Download the latest version of Drupal using wget:

sudo apt install wget -y
wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
 
 

Extract the downloaded archive and move it to a folder named drupal:

sudo tar -xvf drupal.tar.gz
sudo mv drupal-* drupal

Change the ownership of the Drupal directory to the web server user:

sudo chown -R www-data:www-data /var/www/drupal

Set the correct permissions:

sudo find /var/www/drupal -type d -exec chmod 755 {} \;
sudo find /var/www/drupal -type f -exec chmod 644 {} \;

Step 7: Configure Nginx for Drupal

Create a new Nginx server block configuration file for Drupal:

sudo nano /etc/nginx/sites-available/drupal

Add the following configuration to the file, adjusting the server_name and paths as needed:

server {
    listen 80;
    server_name your_domain.com;  # Replace with your domain or server IP

    root /var/www/drupal;
    index index.php index.html index.htm;

    location / {
        try_files $uri /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

Save and exit the file

Enable the new configuration by creating a symbolic link to sites-enabled:

sudo ln -s /etc/nginx/sites-available/drupal /etc/nginx/sites-enabled/

Test the Nginx configuration for syntax errors:

sudo nginx -t

Restart Nginx to apply the changes:

sudo systemctl restart nginx

Step 8: Configure PHP Settings for Drupal

Edit the PHP configuration file to optimize it for Drupal.

Open the PHP-FPM configuration file:

sudo nano /etc/php/8.3/fpm/php.ini

Modify the following values to recommended settings:

memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 300

Restart PHP-FPM to apply the changes:

sudo systemctl restart php8.3-fpm

Step 9: Configure Firewall Settings

Ensure that Nginx can serve traffic by adjusting your firewall settings.

Allow Nginx Full profile:

sudo ufw allow 'Nginx Full'

Check the status of UFW to confirm changes:

sudo ufw status

Step 10: Secure the Drupal Installation

Enable HTTPS: Secure your site by installing an SSL certificate. You can use Let's Encrypt to obtain a free SSL certificate:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d your_domain.com

Follow the prompts to complete the SSL setup.

Step 11: Complete the Drupal Installation via Web Browser

Open your web browser and navigate to your server's domain or IP address:

http://your_domain.com

Follow the on-screen instructions to select your language, configure your database settings (use the database name, user, and password created earlier), and finalize the installation.

Troubleshooting Tips

If you are unable to login into admin panel, rerun the Drupal installation by navigate to:

https://drupal.hnxcode.dev/core/install.php

For other errors:

Nginx Errors: If Nginx fails to start, check the logs in /var/log/nginx/error.log for detailed error messages.
Database Connection Issues: Double-check database credentials in Drupal’s settings file located at /var/www/drupal/sites/default/settings.php.
File Permissions: Ensure the web server user (www-data) has the correct permissions to read and write necessary files.

This guide explained how to install Drupal CMS 11 on Ubuntu 24.04 with Nginx, MariaDB and SSL. Ensure to maintain regular updates and backups for your Drupal site to keep it secure and running smoothly.