Oct 21, 2023 7 min read

How To Install Drupal 9 CMS on Ubuntu 20.04

Install Drupal 9 CMS on Ubuntu 20.04 with our step-by-step tutorial. It is a flexible and robust open-source content management system (CMS).

How To Install Drupal 9 CMS on Ubuntu 20.04
Install Drupal 9 CMS on Ubuntu 20.04
Table of Contents

Choose a different version or distribution


Before we begin talking about how to install Drupal 9 CMS on Ubuntu 20.04, let’s briefly understand – What is Drupal?

Drupal is a flexible and robust open-source content management system (CMS). It enables users to build powerful websites and applications with ease. With a vast community of developers, Drupal offers endless possibilities for customization and scalability, making it a popular choice for businesses of all sizes.

Whether it's a simple blog or a complex e-commerce platform, Drupal provides the tools needed to create and manage content effectively. Harness the potential of Drupal to elevate your online presence and connect with your audience effortlessly.

In this tutorial, you will install Drupal 9 CMS in an independent environment on Ubuntu 20.04. We will also address a few FAQs on how to install Drupal 9 CMS on Ubuntu 20.04.

Advantages of Drupal

  1. Customizability: Drupal's modular architecture allows for extensive customization, enabling users to build tailored websites and applications.
  2. Scalability: With robust performance and scalability features, Drupal can handle high-traffic websites and grow as your needs evolve.
  3. Security: Drupal's strong security framework protects against vulnerabilities and provides regular updates to keep your site secure.
  4. Flexibility: Drupal supports various content types, making it suitable for diverse projects such as blogs, e-commerce, and community portals.
  5. Thriving Community: Drupal has a large community of developers and users who contribute modules, themes, and support, ensuring continuous improvement and innovation.

Install Drupal 9 CMS on Ubuntu 20.04

The PHP-based Drupal software is released under the terms of the GNU General Public License. The conclusion of all the features created throughout Drupal 8 on a leaner, cleaner codebase is Drupal 9. The following are a few features of Drupal 9:

  • Layout Builder: Enables page design by content editors without the assistance of engineers.
  • API-first architecture: Enables the development of reliable headless and decoupled applications.
  • Media Library: Makes it simpler than ever to handle assets like as photos, videos, and other types of media.
  • Automated updates.
  • New admin interface and default theme.

Drupal 9 system Prerequisites

  • PHP : 8.1
  • MySQL or Percona, version : 5.7.8
  • MariaDB : 10.3.7
  • PostgreSQL : 10

The process for installing Drupal 9 CMS on an Ubuntu 20.04 Linux machine can now be discussed.

Step 1: Update System

Ensure your system is running the most recent version:

sudo apt update && sudo apt -y upgrade
[ -f /var/run/reboot-required ] && sudo reboot -f

Wait for the server to start up before continuing with the configuration using ssh.

ssh root@serverip
ssh user@serverip

Step 2: Install MariaDB database server

The database server we'll use is MariaDB. The OS upstream repository contains the packages for this database server. Run the commands listed below to install it.

sudo apt update
sudo apt install -y mariadb-server mariadb-client

Set a root password, disable root remote logins, and delete any unnecessary test databases to secure your database server.

sudo mysql_secure_installation


In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Permit root user logins for regular users with a password.

sudo mysql -u root
UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';

Check to see if you can access the database as the root user with a password.

mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 59
Server version: 10.3.22-MariaDB-1ubuntu1 Ubuntu 20.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)]>

Step 3: Create Drupal Database

Drupal CMS needs a database and a user to function. Launch the MariaDB shell.

mysql -u root -p

For Drupal, create a database and users.

GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost' IDENTIFIED BY 'Str0ngDrupaLP@SS';

Step 4: Install PHP and Apache Web Server

Install PHP on Ubuntu:

sudo add-apt-repository ppa:ondrej/php
sudo apt install php8.1 php8.1-{cli,fpm,common,mysql,zip,gd,intl,mbstring,curl,xml,tidy,soap,bcmath,xmlrpc}

Make sure Apache is installed:

sudo apt install apache2 libapache2-mod-php

Set the RAM limit and PHP timezone.

sudo vim /etc/php/*/apache2/php.ini
memory_limit = 256M
date.timezone = Africa/Nairobi

Step 5: Download Drupal 9 on Ubuntu 20.04

Download the Drupal 9 tarball to the server hosting the service.

wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz

Extract downloaded file.

tar xvf drupal.tar.gz

Transfer the finished folder to the /var/www/html directory.

rm -f drupal*.tar.gz
sudo mv drupal-*/  /var/www/html/drupal

Verify file contents:

ls /var/www/html/drupal

autoload.php   core               INSTALL.txt  profiles    sites       vendor
composer.json  example.gitignore  LICENSE.txt  README.txt  themes      web.config
composer.lock  index.php          modules      robots.txt  update.php

Set the Apache user and group as the directory's owners for Drupal.

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

Step 6: Configure Apache for Drupal

On Ubuntu, disable the default site:

sudo a2dissite 000-default.conf
sudo rm /var/www/html/index.html
sudo systemctl restart apache2

For the Drupal website, create a new Apache setup.

sudo vim /etc/apache2/sites-available/drupal.conf

Change the text below and add it to the file, setting the domain, admin user, and the proper path to the Drupal data.

<VirtualHost *:80>
     ServerName mysite.com
     ServerAlias www.mysite.com
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/drupal/

     CustomLog ${APACHE_LOG_DIR}/access.log combined
     ErrorLog ${APACHE_LOG_DIR}/error.log

      <Directory /var/www/html/drupal>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
            RewriteEngine on
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Verify configuration syntax:

sudo apachectl -t

Activate website:

sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.1-fpm
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
sudo a2enmod rewrite
sudo a2ensite drupal.conf
sudo systemctl restart apache2

Step 7: Drupal 9 should be installed on Ubuntu 20.04

A working DNS entry set up in Apache is necessary for Drupal's web configuration to start. Web interface access on:


Choose Language:

Choose language

Select an installation profile:

Installation Profile

Set up the Drupal database. Our initial database creation's username, database name, and password are "drupal" and "Str0ngDrupaLP@SS," respectively.

Database Configuration

Installation of Drupal has begun. Wait for it to finish.

Installation Begins

Set up the site's settings and establish an admin user.

Set up site settings

Configure your site:

Congratulation Mesage

FAQs to Install Drupal 9 CMS on Ubuntu 20.04

Can I install Drupal on Ubuntu 18.04 instead of 20.04?

Yes, you can follow similar steps to install Drupal on Ubuntu 18.04. Just make sure to adjust any package versions or dependencies accordingly.

How do I check if LAMP stack is installed?

You can run sudo systemctl status apache2 to check the status of Apache. Similarly, you can check MySQL and PHP status using sudo systemctl status mysql and php -v respectively.

Is it necessary to create a new MySQL database for Drupal installation?

Yes, Drupal requires a dedicated MySQL database to store its data. It is recommended to create a new database and assign a dedicated MySQL user for Drupal.

Can I use a different web server instead of Apache?

Yes, Drupal supports other web servers like Nginx. You would need to follow the respective installation and configuration steps specific to your chosen web server.

How can I secure my Drupal installation?

Ensure you keep Drupal and its modules updated. Use strong passwords, implement secure server configurations, install security modules, and follow best practices provided by Drupal's security team.

Can I change the default theme in Drupal?

Yes, you can change the default theme in Drupal. Navigate to Administer > Appearance in the Drupal admin interface, select and enable the desired theme.

How to upgrade Drupal to a newer version?

Upgrading Drupal may involve backing up your site, disabling non-core modules, updating core files, running database updates, and re-enabling modules. Detailed upgrade instructions specific to your Drupal version can be found in Drupal's official documentation.


Enjoy Drupal 9's power in your website. For more tuning and complex configurations, consult the official manual. If you have any queries or doubts, please leave them in the comment below. We'll be happy to address them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Blog - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.