Drupal is an open-source content management system (CMS) built in PHP. It powers everything from personal blogs to enterprise websites, government portals, and e-commerce platforms. Drupal stands out for its flexibility, strong security track record, and a modular architecture that supports thousands of contributed modules.
This guide walks through installing Drupal 11 on Ubuntu 24.04 LTS with Apache, MariaDB, and PHP 8.3. By the end, you will have a working Drupal site with clean URLs, a firewall, and SSL encryption via Let’s Encrypt.
Prerequisites
Before starting, make sure you have the following in place:
- A server running Ubuntu 24.04 LTS with at least 2 GB RAM and 20 GB disk space
- Root or sudo access to the server
- A registered domain name pointing to your server’s public IP address
- A stable internet connection for downloading packages
Step 1: Install Apache Web Server
Apache is one of the officially supported web servers for Drupal. Start by updating the package index and installing Apache.
sudo apt update
sudo apt install apache2 -y
After installation, enable Apache to start automatically on boot and start the service.
sudo systemctl enable --now apache2
Verify that Apache is running.
sudo systemctl status apache2
The output should show the service as active (running):
● apache2.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; preset: enabled)
Active: active (running) since Sat 2026-03-22 10:15:32 UTC; 5s ago
Enable the rewrite module – Drupal requires it for clean URLs.
sudo a2enmod rewrite
Step 2: Install PHP and Required Extensions
Drupal 11 requires PHP 8.3 or newer. Ubuntu 24.04 ships with PHP 8.3 in the default repositories, so no third-party PPAs are needed. Install PHP along with all the extensions Drupal requires.
sudo apt install php php-cli php-common php-mysql php-xml php-gd php-curl php-mbstring php-zip php-opcache php-apcu libapache2-mod-php -y
Here is what each extension does:
php-mysql– PDO MySQL/MariaDB driver for database connectivityphp-xml– XML parsing, required by Drupal corephp-gd– Image manipulation for thumbnails and image stylesphp-curl– HTTP requests for fetching remote dataphp-mbstring– Multibyte string support for Unicode contentphp-zip– Required by Composer for extracting packagesphp-opcache– Bytecode caching for better PHP performancephp-apcu– User-level caching that Drupal uses for fast data lookups
Confirm the installed PHP version.
php -v
You should see PHP 8.3 confirmed in the output:
PHP 8.3.6 (cli) (built: Mar 2 2026 12:24:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies
Adjust the PHP configuration for Drupal. Open the PHP configuration file for Apache.
sudo vi /etc/php/8.3/apache2/php.ini
Update these settings to match Drupal’s recommended values:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
date.timezone = UTC
Restart Apache to apply the PHP changes.
sudo systemctl restart apache2
Step 3: Install MariaDB Database Server
Drupal needs a database backend. MariaDB is a solid choice – it is fully compatible with MySQL and ships in the Ubuntu default repositories.
sudo apt install mariadb-server mariadb-client -y
Enable and start the MariaDB service.
sudo systemctl enable --now mariadb
Run the security hardening script to set a root password, remove anonymous users, and disable remote root login.
sudo mariadb-secure-installation
Answer the prompts as follows:
- Enter current password for root – press Enter (no password set yet)
- Switch to unix_socket authentication – No
- Change the root password – Yes (set a strong password)
- Remove anonymous users – Yes
- Disallow root login remotely – Yes
- Remove test database – Yes
- Reload privilege tables – Yes
Step 4: Create Drupal Database and User
Log into the MariaDB shell and create a dedicated database and user for Drupal.
sudo mariadb -u root -p
Run the following SQL commands to create the database, user, and grant privileges. Replace StrongPassword123 with your own secure password.
CREATE DATABASE drupal_db CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'drupal_user'@'localhost' IDENTIFIED BY 'StrongPassword123';
GRANT ALL PRIVILEGES ON drupal_db.* TO 'drupal_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
The utf8mb4 character set is required by Drupal for full Unicode support including emojis.
Step 5: Download Drupal with Composer
The recommended way to install Drupal is through Composer, the PHP dependency manager. This makes future updates and module management straightforward. First, install Composer.
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
Verify the Composer installation.
composer --version
The output confirms the installed Composer version:
Composer version 2.8.6 2025-10-08 14:30:52
Now create the Drupal project using Composer. This downloads Drupal core and all its dependencies into the /var/www/drupal directory.
cd /var/www
sudo composer create-project drupal/recommended-project drupal
Set the correct ownership so Apache can read and write to the Drupal files.
sudo chown -R www-data:www-data /var/www/drupal
sudo chmod -R 755 /var/www/drupal
Step 6: Configure Apache Virtual Host for Drupal
Create an Apache virtual host configuration file for your Drupal site. Replace example.com with your actual domain name throughout this section.
sudo vi /etc/apache2/sites-available/drupal.conf
Add the following virtual host configuration:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/drupal/web
ServerAdmin [email protected]
<Directory /var/www/drupal/web>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/drupal_error.log
CustomLog ${APACHE_LOG_DIR}/drupal_access.log combined
</VirtualHost>
The AllowOverride All directive is critical – it allows Drupal’s .htaccess file to control URL rewriting and access rules.
Enable the new site and disable the default Apache site.
sudo a2ensite drupal.conf
sudo a2dissite 000-default.conf
Test the Apache configuration for syntax errors before restarting.
sudo apachectl configtest
You should see this confirmation if the configuration is correct:
Syntax OK
Restart Apache to apply the changes.
sudo systemctl restart apache2
Step 7: Run the Drupal Web Installer
Before launching the web installer, create the settings file and the files directory that Drupal needs.
cd /var/www/drupal/web
sudo cp sites/default/default.settings.php sites/default/settings.php
sudo mkdir -p sites/default/files
sudo chown -R www-data:www-data sites/default/settings.php sites/default/files
Open your web browser and navigate to your server’s domain name or IP address:
http://example.com
The Drupal installation wizard walks you through these screens:
- Choose language – Select your preferred language and click Save and continue
- Choose profile – Select Standard for a full-featured installation with commonly used modules
- Database configuration – Select MySQL/MariaDB and enter the database name (
drupal_db), username (drupal_user), and password you created in Step 4 - Install Drupal – The installer runs automatically. Wait for it to complete
- Configure site – Enter your site name, admin email, username, and password
After the installer finishes, you will be redirected to the Drupal admin dashboard.
Step 8: Configure .htaccess for Clean URLs
Drupal uses clean URLs by default (like /about instead of /?q=about). This depends on the Apache rewrite module, which we enabled in Step 1. Verify that the .htaccess file exists in the Drupal web root.
ls -la /var/www/drupal/web/.htaccess
The file should already exist from the Composer installation:
-rw-r--r-- 1 www-data www-data 7298 Mar 22 10:30 /var/www/drupal/web/.htaccess
Verify clean URLs are working by visiting a Drupal page like http://example.com/admin/config. If the page loads without errors, clean URLs are active.
If clean URLs are not working, confirm the rewrite module is loaded.
sudo apache2ctl -M | grep rewrite
You should see the module listed as enabled:
rewrite_module (shared)
Step 9: Configure UFW Firewall
Ubuntu 24.04 uses UFW (Uncomplicated Firewall) by default. Allow HTTP (port 80/TCP) and HTTPS (port 443/TCP) traffic so visitors can reach your Drupal site.
sudo ufw allow 'Apache Full'
sudo ufw enable
Verify the firewall rules are active.
sudo ufw status
The output should show both HTTP and HTTPS ports open:
Status: active
To Action From
-- ------ ----
Apache Full ALLOW Anywhere
OpenSSH ALLOW Anywhere
Apache Full (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
Make sure you also have SSH (port 22) allowed if you are managing the server remotely. If it is not listed, add it before enabling UFW to avoid locking yourself out.
sudo ufw allow OpenSSH
Step 10: Enable SSL with Let’s Encrypt
Running Drupal over HTTPS is essential for security. Let’s Encrypt provides free SSL certificates. Install Certbot and the Apache plugin.
sudo apt install certbot python3-certbot-apache -y
Run Certbot to obtain and install the SSL certificate. Replace example.com with your domain.
sudo certbot --apache -d example.com -d www.example.com
Certbot will ask for your email address and whether to redirect HTTP to HTTPS. Choose to redirect all traffic to HTTPS for best security.
Verify the certificate is installed and auto-renewal is configured.
sudo certbot renew --dry-run
If the dry run completes without errors, automatic renewal is working. Certbot creates a systemd timer that checks for renewal twice daily.
After SSL is enabled, update the Drupal trusted host setting. Open the settings file.
sudo vi /var/www/drupal/web/sites/default/settings.php
Add these lines at the bottom of the file to restrict which hostnames Drupal accepts. Replace example\.com with your domain (escape the dot with a backslash):
$settings['trusted_host_patterns'] = [
'^example\.com$',
'^www\.example\.com$',
];
This prevents HTTP host header attacks and is a recommended security hardening step for production Drupal sites.
Conclusion
You now have Drupal 11 running on Ubuntu 24.04 with Apache, MariaDB, PHP 8.3, clean URLs, a UFW firewall, and SSL encryption from Let’s Encrypt. The site is ready for content creation and module installation through the admin dashboard.
For a production environment, consider setting up automated database backups, configuring a caching layer like Redis or Varnish, and monitoring server resources. Keep Drupal and its modules updated regularly by running composer update from the project root. Check the Drupal system requirements page when upgrading to confirm compatibility with your PHP and database versions.
Thanks — this is the only modern guide that worked for me without much tinkering.
We’re happy it worked for you!