How to install Drupal with Apache support on Ubuntu 24.04
Installing Drupal 10 with Apache on Ubuntu 24.04 configures the Ubuntu 24.04 system by setting up Apache as your web server. This Apache configuration then links Drupal 10's files together, making a working Drupal website for you.
Drupal is a free and open-source content management system (CMS) known for its flexibility in building everything from personal blogs to large enterprise websites. It requires a web server like Apache to run.
Apache, a reliable web server, provides the infrastructure for Drupal to function. Setting up Apache and Drupal on Ubuntu 24.04 ensures a solid foundation for your web projects.
Install Apache using `sudo apt install apache2`, then set up a MariaDB database with `sudo mariadb`. Create a database and user for Drupal, and finally, install PHP.
Install Apache HTTP server on Ubuntu Linux
Install the Apache web server on Ubuntu 24.04 to handle requests for your Drupal site. Apache is a popular and reliable choice for running Drupal on Ubuntu. You can easily install it using simple commands in your terminal, which prepares your system to serve your Drupal site.
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.
Install MariaDB database server on Ubuntu Linux
Drupal needs a database to store all its content and settings, and MariaDB is a great choice for Ubuntu 24.04. Installing MariaDB is straightforward using a command in your terminal. This step sets up the database system that Drupal will use to keep your website’s information organised and accessible.
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.
- How to install MariaDB on Ubuntu Linux
- MariaDB without password prompt
Create a Drupal database
After installing MariaDB, create a specific database for Drupal to hold its data. You’ll create a database named ‘drupaldb’ and a user ‘drupaldbuser’ with the right permissions. This dedicated space ensures Drupal can store and manage all its application content and settings securely.
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.
Grant drupaldbuser full access to the drupaldb database, allowing the Drupal application to create and manage tables necessary for its operation. This step ensures that Drupal can properly store and retrieve all its content and configuration data on the MySQL server.
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
Drupal is built with PHP, so you must install it on your Ubuntu 24.04 system for your website to work. You can install PHP and the necessary modules with a single command in the terminal. This ensures your server can run the PHP code that makes Drupal function properly.
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
Download Drupal files
Once your server is set up, download the Drupal files to your Ubuntu 24.04 system. You’ll place these files in the correct folder so Apache can find them, which puts the actual Drupal website software onto your server. The command provided will download Drupal and create a new folder in the Apache root directory.
First, create a Drupal folder in the Apache root directory.
Apache web server permissions must change to allow the web server to read Drupal files for proper website operation. Specifically, you should set the ownership of the Drupal installation directory to the Apache user, which is typically `www-data` on Ubuntu 24.04. This ensures Apache can access and serve the Drupal core, modules, and themes correctly.
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.
The server block enables Apache to serve your Drupal website. Run the commands `sudo a2ensite drupal.conf` and `sudo systemctl restart apache2` to turn on the server block and restart the Apache server for your Drupal installation.
sudo a2ensite drupal.conf
sudo a2enmod rewrite
sudo systemctl reload apache2
sudo systemctl restart apache2
Setup Let’s Encrypt SSL/TLS for Drupal
Secure your Drupal website by setting up an SSL/TLS certificate with Let’s Encrypt. This makes your site trustworthy by encrypting data between visitors and your server, ensuring a safe connection. Setting up SSL/TLS is important for protecting user data and building confidence in your Drupal installation.
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.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!