How to install Drupal with Apache support on Ubuntu 24.04
Drupal with Apache on Ubuntu 24.04 sets up a free content management system (CMS) to build and run websites on your server. Drupal is open-source software that stores your site pages, while Apache acts as the web server to load them for visitors.
Ubuntu 24.04 hosts all these files and services on your system. This setup gets your new website online and ready for content.
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 Apache HTTP server on Ubuntu Linux to handle incoming web traffic for your Drupal site. Apache is a reliable web server that works well with PHP and MySQL. Open your terminal and run the standard package manager commands to download and start the Apache service on your system.
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
Install MariaDB database server on Ubuntu Linux to store all your Drupal site content, user accounts, and settings. MariaDB is a fast and open-source database system that connects securely with PHP. Use the terminal to install the server package and complete the basic security setup.
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
Create a Drupal database in MariaDB by opening the database command line interface and running SQL queries. You need a dedicated database and a secure user account so Drupal can read and write application data without sharing permissions with other services.
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
Install PHP on Ubuntu Linux
Install PHP on Ubuntu Linux along with the required modules like php-mysql and php-intl to make Drupal run correctly. Drupal is built on PHP, and your server needs these specific software extensions to process site code, handle languages, and connect to your database.
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
Download Drupal files directly to your Ubuntu web directory using the command line tool wget or curl. This places the core website software into the correct Apache folder so visitors can load your new site in their web browsers.
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.
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
Setup Let's Encrypt SSL/TLS for Drupal to encrypt all traffic between your visitors and your server. An SSL certificate protects user passwords and personal data while helping your site build trust and rank better in search engines.
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 is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!