Website Vidya
Linux & ServersStep-by-Step Guide

How to Install Drupal on Ubuntu 24.04

Learn how to install Drupal on Ubuntu 24.04 LTS with Apache, MariaDB, PHP 8.3, and Composer. Enterprise open-source CMS deployment tutorial.

RR
Rajesh RayLead Systems Educator
Published:
6 min read
PDF Cheat Sheet
How to Install Drupal on Ubuntu 24.04
AI Executive SummaryWebsiteVidya AI

6 min read

Learn how to install Drupal on Ubuntu 24.04 LTS with Apache, MariaDB, PHP 8.3, and Composer. Enterprise open-source CMS deployment tutorial.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Updating System Packages and Installing Apache and MariaDB
  • Step 2: Installing PHP 8.3 and Required Drupal Extensions
Grounded in full engineering runbookWebsiteVidya AI Engine

Drupal is an enterprise-grade, open-source Content Management System (CMS) renowned for its uncompromising security architecture, powerful taxonomy management, customizable content entities, and sophisticated access control hierarchies. Trusted by global brands, government agencies, universities, and healthcare organizations, Drupal is designed to manage complex digital experiences and large-scale editorial workflows.

Modern Drupal releases (Drupal 10 and Drupal 11) are built on robust Symfony components, object-oriented PHP architecture, and Twig templating engines. Learning how to install drupal on ubuntu 24.04 using official Composer scaffolding gives you complete control over core updates, third-party contributed modules, and automated CI/CD deployments on a stable, long-term support operating system.

In this comprehensive step-by-step tutorial, we demonstrate how to install Drupal on Ubuntu 24.04 LTS (Noble Numbat) using the modern LAMP stack (Apache, MariaDB, PHP 8.3, and Composer). We guide you through configuring prerequisite PHP modules, provisioning a dedicated database, managing directory permissions, setting up Apache Virtual Hosts pointing to the web docroot, and securing your site with Let's Encrypt SSL.

Advertisement

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

  • A virtual private server (VPS) or dedicated server running Ubuntu 24.04 LTS.
  • A non-root user account configured with sudo administrative privileges.
  • A registered domain name (e.g., drupal.example.com) pointed to your server IP address.
  • At least 2 GB of RAM (4 GB or more recommended for enterprise workloads and Composer dependency builds).

Step 1: Updating System Packages and Installing Apache and MariaDB

Drupal requires a robust HTTP web server and a relational database backend. In this tutorial, we configure the Apache web server and MariaDB database server.

Update your package repository lists and install apache2, mariadb-server, and standard file manipulation tools using APT.

Advertisement

Verify that both services start successfully and are set to launch at system boot.

# Update repository indices
sudo apt update && sudo apt upgrade -y

# Install Apache web server and MariaDB database server
sudo apt install -y apache2 mariadb-server mariadb-client curl wget git unzip

# Enable and verify services
sudo systemctl enable --now apache2 mariadb

Step 2: Installing PHP 8.3 and Required Drupal Extensions

Drupal 10 and 11 require PHP 8.1, 8.2, or 8.3 alongside specific modules for XML parsing, multi-byte string handling, internationalization, and graphics rendering.

Install PHP 8.3 and its necessary modules: libapache2-mod-php, php-mysql, php-curl, php-gd, php-intl, php-mbstring, php-xml, php-zip, and php-opcache.

Tune PHP settings in /etc/php/8.3/apache2/php.ini: increase memory_limit = 256M, max_execution_time = 300, and ensure OPcache is enabled for fast page response times.

Advertisement

Restart Apache to apply the new PHP configuration.

# Install PHP 8.3 and required extensions
sudo apt install -y php libapache2-mod-php php-mysql php-curl php-gd php-intl php-mbstring php-xml php-zip php-opcache php-apcu

# Restart Apache
sudo systemctl restart apache2

Step 3: Installing Composer Globally

Modern Drupal installations are managed exclusively via Composer, the PHP dependency manager. Composer manages Drupal core, third-party libraries, and contributed modules seamlessly.

Download and install the latest stable Composer binary directly into /usr/local/bin/composer.

Verify that the Composer executable is accessible system-wide.

# Download official Composer installer
curl -sS https://getcomposer.org/installer | php

# Move binary to system path
sudo mv composer.phar /usr/local/bin/composer

# Verify Composer version
composer --version

Step 4: Creating the Drupal Database and User

Drupal requires a dedicated relational database configured with full Unicode support (utf8mb4).

Log into the MariaDB shell as root.

Create the database drupal_db with utf8mb4_general_ci collation, create user drupal_user, grant full privileges, and flush privileges.

Ensure you replace StrongDrupalPassword123! with a randomized, secure password.

-- Access MariaDB root shell
sudo mariadb

-- Create Drupal database with utf8mb4 encoding
CREATE DATABASE drupal_db CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

-- Create dedicated user
CREATE USER 'drupal_user'@'localhost' IDENTIFIED BY 'StrongDrupalPassword123!';

-- Grant database privileges
GRANT ALL PRIVILEGES ON drupal_db.* TO 'drupal_user'@'localhost';

-- Apply changes and exit
FLUSH PRIVILEGES;
EXIT;

Step 5: Provisioning Drupal via Composer

Use Composer's official drupal/recommended-project template to bootstrap a clean, standardized Drupal project in /var/www/drupal.

This structure places core vendor libraries and configuration files outside the public web root, exposing only the web/ subdirectory to the internet for superior security.

Run the project creation command as your standard user, then move the directory to /var/www/.

# Bootstrap Drupal project using Composer
cd /tmp
composer create-project drupal/recommended-project drupal

# Move project directory to /var/www/
sudo mv drupal /var/www/drupal

# Verify directory structure
ls -la /var/www/drupal

Step 6: Setting File Permissions and Configuring settings.php

To allow the Drupal installer to write configuration files and store user media uploads, configure directory permissions carefully.

Create the public files directory at /var/www/drupal/web/sites/default/files and prepare the settings.php configuration file from the default template.

Assign ownership of the web root to the www-data user.

# Create files directory and settings.php
sudo mkdir -p /var/www/drupal/web/sites/default/files
sudo cp /var/www/drupal/web/sites/default/default.settings.php /var/www/drupal/web/sites/default/settings.php

# Assign ownership to www-data
sudo chown -R www-data:www-data /var/www/drupal
sudo chmod -R 755 /var/www/drupal
sudo chmod 660 /var/www/drupal/web/sites/default/settings.php

Step 7: Configuring Apache Virtual Host for Drupal

Create a dedicated Apache Virtual Host configuration for your Drupal domain.

Notice that the DocumentRoot must point strictly to /var/www/drupal/web, rather than the top-level project root.

Enable the Apache rewrite and headers modules, activate the site, and restart Apache.

# Create virtual host definition
sudo bash -c 'cat <<EOF > /etc/apache2/sites-available/drupal.conf
<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/drupal/web
    ServerName drupal.example.com

    <Directory /var/www/drupal/web>
        Options -Indexes +FollowSymlinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/drupal_error.log
    CustomLog ${APACHE_LOG_DIR}/drupal_access.log combined
</VirtualHost>
EOF'

# Enable rewrite module and site
sudo a2enmod rewrite headers
sudo a2ensite drupal.conf
sudo a2dissite 000-default.conf
sudo systemctl restart apache2

Step 8: Securing Drupal with SSL and Completing Web Setup

Encrypting user logins, API authentication tokens, and editorial sessions is mandatory for enterprise web platforms.

Use Certbot to obtain and configure a free Let's Encrypt SSL certificate for your Drupal domain.

Once HTTPS is active, open your web browser and navigate to https://drupal.example.com to run the web installation wizard.

Choose the Standard profile, enter your database connection details (Database Name: drupal_db, Username: drupal_user, Password: StrongDrupalPassword123!), configure your site name and admin account, and complete setup.

After installation, lock down settings.php permissions: sudo chmod 440 /var/www/drupal/web/sites/default/settings.php.

# Install Certbot and apply SSL
sudo apt install -y certbot python3-certbot-apache
sudo certbot --apache -d drupal.example.com

# Lock down settings.php after web installer finishes
sudo chmod 440 /var/www/drupal/web/sites/default/settings.php

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

Trusted host settings not configured warning in Drupal status report

Resolution: Open /var/www/drupal/web/sites/default/settings.php and append your domain pattern: $settings['trusted_host_patterns'] = ['^drupal\.example\.com$'];.

Clean URLs do not work / subpages return 404 Not Found

Resolution: Verify that Apache's mod_rewrite is enabled (sudo a2enmod rewrite) and ensure that AllowOverride All is set inside /etc/apache2/sites-available/drupal.conf.

Composer out of memory error during module installation

Resolution: Increase PHP memory limit or temporarily disable Composer's memory limit when installing modules: COMPOSER_MEMORY_LIMIT=-1 composer require drupal/token.

Security Best Practices and Hardening

Always restrict permissions on sites/default/settings.php to 0440 after installation to prevent unauthorized configuration changes.

Never point Apache DocumentRoot to the project root directory; always point it to the /var/www/drupal/web subdirectory to keep vendor files hidden.

Use Composer to install core and security updates rather than uploading files via FTP to prevent dependency mismatch.

Regularly run composer audit to scan third-party PHP libraries for known CVE vulnerabilities.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

3 FAQs
Yes! Drush (the Drupal Shell) is the official CLI tool for Drupal. You can install it locally in your project using composer require drush/drush and execute commands via ./vendor/bin/drush.
Separating the public web assets (in web/) from private configuration files, vendor code, and Composer manifests ensures that unauthorized visitors cannot read internal PHP dependencies or environmental secrets.
To upgrade Drupal core, navigate to your project directory and execute composer update 'drupal/core-*' --with-all-dependencies followed by running database updates via Drush: ./vendor/bin/drush updatedb.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout