This article explains how to install Drupal with Apache support on Ubuntu 24.04.
Drupal, a free and open-source content management system (CMS), is a feature-rich website creation and management tool. It caters to a spectrum of needs, from personal blogs to robust enterprise applications.
When installing Drupal, choosing Apache support on Ubuntu is a great choice. Apache, a widely used web server, is renowned for its reliability and performance. When paired with Drupal, it creates a stable and efficient environment, ensuring your website is in safe hands.
The Apache-Drupal combination not only offers compatibility with various modules and extensions but also expands your Drupal site’s functionality.
The steps below will walk you through the process of getting it working on Ubuntu securely with a free Let’s Encrypt SSL certificate.
Install Apache HTTP server on Ubuntu Linux
Drupal is a web application that requires a web server. For this post, we will install and use the Apache web server to run Drupal.
To do that, open the Ubuntu terminal and run the commands below to install the Apache web server.
sudo apt update
sudo apt install apache2
Once Apache is installed, the commands below can start, stop, and enable the Apache web server to start automatically when your server boots up.
sudo systemctl stop apache2
sudo systemctl start apache2
sudo systemctl enable apache2
You test that the Apache web server is running by opening your web browser and browsing to the server’s localhost or IP address.
http://localhost

When you see the Apache2 Default Page, it means the Apache HTTP server is successfully installed.
Additional help on installing Apache on Ubuntu is in the link below.
How to install Apache on Ubuntu
Install MariaDB database server on Ubuntu Linux
The next component that is required to run Drupal is a database server. This post will install and use the MariaDB database server to run Drupal.
To install and use the MariaDB database server, use the instructions below.
Open the Ubuntu terminal and run the commands below to install the MariaDB database server.
sudo apt update sudo apt install mariadb-server
Once the MariaDB database server is installed, use the commands below to stop, start, and enable the MariaDB server to start automatically when the server boots.
sudo systemctl stop mariadb sudo systemctl start mariadb sudo systemctl enable mariadb
Run the following commands to validate and test if the MariaDB database server is installed successfully.
sudo mariadb
Once you run the commands above, it will log you onto the MariaDB console and display a message similar to the one below.
Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 32 Server version: 10.11.2-MariaDB-1 Ubuntu 23.04 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
The message tells you that the server is installed successfully.
Additional help on installing MariaDB.
Create a Drupal database
After installing the MariaDB database server, you should create a blank database for the Drupal application on the server.
This database will store the Drupal application content and data.
We will create a database called drupaldb. We will also create a database user account called drupaldbuser.
Finally, we’ll grant the drupaldbuser full access to the drupaldb database.
All the database steps above can be done using the commands below:
But first, log on to the MariaDB database server:
sudo mariadb
Then run the commands below to complete the steps:
CREATE DATABASE drupaldb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER drupaldbuser@localhost IDENTIFIED BY 'type_your_password_here';
GRANT ALL ON drupaldb.* TO drupaldbuser@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
Ensure to replace ‘type_your_password_here‘ with your password.
Install PHP on Ubuntu Linux
The last component you will need to run Drupal is PHP. The Drupal application is a PHP-based application. It supports the latest versions of PHP.
Run the commands below to install PHP.
sudo apt install php libapache2-mod-php php-intl php-mysql php-curl php-cli php-zip php-gd php-common php-mbstring php-xml php-opcache php-readline php-sqlite3 php-zip php-apcu
Additional help on installing PHP
How to install PHP on Ubuntu Linux
Download Drupal files
We are ready to download and configure the Drupal files on Ubuntu Linux. Run the commands below to download and extract the Drupal files to the Apache web server root directory.
The command block below will download and create a new Drupal folder in the Apache root directory.
First, create a Drupal folder in the Apache root directory.
Please change it to the /tmp directory and download Drupal files. Unzip the file and move the content into the created Drupal folder.
Finally, the permissions should be changed to allow the Apache web server to interact with the files.
sudo mkdir -p /var/www/drupal
cd /tmp/
wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
tar -xvf drupal.tar.gz
sudo mv drupal-*/* /var/www/drupal
sudo chown -R www-data:www-data /var/www/drupal/
sudo chmod -R 755 /var/www/drupal/
Once you have completed all the above steps, continue below to configure the Apache web server to serve the Drupal content.
Run the commands below to create an Apache virtual host file for Drupal.
sudo nano /etc/apache2/sites-available/drupal.conf
Then, copy and paste the content block below into the Apache server block.
<VirtualHost *:80>
ServerName drupal.example.com
ServerAlias www.drupal.example.com
ServerAdmin admin@example.com
DocumentRoot /var/www/drupal
<Directory /var/www/drupal/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/drupal/>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
</VirtualHost>
Save the file.
Then, run the commands below to enable the server block and restart the Apache server.
sudo a2ensite drupal.conf
sudo a2enmod rewrite
sudo systemctl reload apache2
sudo systemctl restart apache2
Setup Let’s Encrypt SSL/TLS for Drupal
You may want to install an SSL/TLS certificate to secure your Drupal site. Secure your Drupal installation with HTTPS from Let’s Encrypt.
Please read the post below for additional resources on installing and creating Let’s Encrypt SSL certificates for Apache.
How to set up Let’s Encrypt SSL certificate for Apache on Ubuntu Linux
After installing, the Apache server block file /etc/apache2/sites-available/drupal.conf will automatically be configured with HTTPS, done by the Certbot Apache plugin.
Once you have restarted the Apache web server, open your browser and browse to the server hostname or IP address defined in the Apache server block.
http://drupal.example.com
A new Drupal installation wizard will appear. Choose a language and continue to the next page.

Next, select the installation profile.

Then, type in the database name, username, and password created above.

Finally, set up your site name and create an admin account to login in.

Your new Drupal site should be created and ready to use.

That should do it!
Conclusion:
- Installing Drupal with Apache support on Ubuntu is a robust choice for creating and managing websites of varying complexities.
- Combining Apache and Drupal ensures compatibility with modules and extensions, creating a stable and efficient environment.
- Let’s Encrypt SSL/TLS for Drupal to secure the site with HTTPS, enhancing its security and trustworthiness.
- The step-by-step guide provided comprehensive instructions for installing and configuring Drupal with Apache support, ensuring a successful setup.
- Users are encouraged to provide feedback or seek additional assistance via the comments section for queries or improvements.
Leave a Reply