How to Install Drupal on Ubuntu 22.04 | PKAREA

August 10, 2022
0 0

how to install drupal on ubuntu 22.04

In this tutorial, we are going to show you in step-by-step detail how to install Drupal on Ubuntu 22.04 OS.

Drupal is a free and open-source CMS(Content Management System) written in PHP. Drupal allows us to customize the webpage easily according to our needs. Drupal is used by millions of people and organizations around the globe to build and maintain their websites. In this installation, we will install Drupal and make the website up and running with the LAMP stack.

For this installation, we will need around 15 minutes. Let’s get started!


  • A server with Ubuntu 22.04 as OS
  • User privileges: root or non-root user with sudo privileges

Step 1. Update the System

Before we start to install the software, we need to update the system packages to the latest versions available.

sudo apt-get update -y && sudo apt-get upgrade -y

Step 2. Install Apache Web Server

To install the Apache Web server execute the following command:

sudo apt install apache2

Once installed, start and enable the service.

sudo systemctl enable apache2 && sudo systemctl start apache2

Check if the service is up and running:

sudo systemctl status apache2

You should receive the following output:

root@vps:~# sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-06-17 16:10:39 UTC; 1 day 3h ago
   Main PID: 667 (apache2)
      Tasks: 9 (limit: 4579)
     Memory: 22.1M
        CPU: 14.658s
     CGroup: /system.slice/apache2.service
             ├─  667 /usr/sbin/apache2 -k start
             ├─24399 /usr/sbin/apache2 -k start
             ├─24400 /usr/sbin/apache2 -k start
             ├─24401 /usr/sbin/apache2 -k start
             ├─24402 /usr/sbin/apache2 -k start
             ├─24403 /usr/sbin/apache2 -k start
             ├─24404 /usr/sbin/apache2 -k start
             ├─24405 /usr/sbin/apache2 -k start
             └─24406 /usr/sbin/apache2 -k start

Jun 17 16:10:38 host.test.vps systemd[1]: Starting The Apache HTTP Server...

Step 3. Install PHP8.1 with dependencies

To install PHP8.1 with extensions, execute the following commands:

sudo apt-get install php8.1 php8.1-cli php8.1-common php8.1-imap php8.1-redis php8.1-snmp php8.1-xml php8.1-zip php8.1-mbstring php8.1-curl libapache2-mod-php

Step 4. Install MariaDB database server

To install the MariaDB database server, execute the command below.

sudo apt install mariadb-server

Start and enable the mariadb.service with the following commands:

sudo systemctl start mariadb && sudo systemctl enable mariadb

Check the status of the mariadb.service

sudo systemctl status mariadb

You should receive the following output:

root@host:~# sudo systemctl status mariadb
● mariadb.service - MariaDB 10.6.7 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-06-18 19:25:52 UTC; 1min 2s ago
       Docs: man:mariadbd(8)
   Main PID: 44866 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 9 (limit: 4579)
     Memory: 57.0M
        CPU: 3.498s
     CGroup: /system.slice/mariadb.service
             └─44866 /usr/sbin/mariadbd

Step 5. Create Drupal Database and User

Next, we need to create a Drupal database, a Drupal user, and grant the permissions for that user to the database.

 CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'YourStrongPasswordHere';
 GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost';

Step 6. Download and Install Drupal

Before we install Drupal, first, we need to download it in the default Apache document root:

cd /var/www/html



mv drupal-9.3.16/ drupal/

Set the right permissions to files and folders.

chown -R www-data:www-data drupal/

find . -type d -exec chmod 755 {} \;

find . -type f -exec chmod 644 {} \;

Step 7. Create Apache Virtual Host File

Go into the Apache directory and create a configuration file for the Drupal CMS.

cd /etc/apache2/sites-available/

touch drupal.conf

Open the file, paste the following lines of code, save the file and close it.

<VirtualHost *:80>
DocumentRoot /var/www/html/drupal

<Directory /var/www/html/drupal>
AllowOverride All

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


Enable the Apache configuration for Drupal and rewrite the module.

sudo a2enmod rewrite

sudo a2ensite drupal.conf

Check the syntax:

apachectl -t

You should receive the following output:

root@vps:~# apachectl -t
Syntax OK

If the syntax is OK, restart the Apache service.

systemctl reload apache2

Once the Apache service is restarted, you can finish the Drupal installation at

Step 8. Finish the installation

Access your Drupal website at to finish the installation.

On the second window, choose the standard installation and click the Save and Continue button.

The next step is to enter the database credentials created in Step 5. in this tutorial.

Once the database setup is done, you need to allow some time for the installation.

The last step is to configure the website specifications like website name, username, password, contact email and etc.

After the creation of the username and password, you will be automatically logged into the Drupal dashboard.

That was all. You successfully installed and configured Drupal 9 on Ubuntu 22.04 with the LAMP stack.

If you do not want to configure it on your own, you can sign up for one of our NVMe VPS plans and submit a support ticket. Our admins are available 24/7 and will start work on your request immediately. Always trust our epic support.

If you liked this post on how to install Drupal on Ubuntu 22.04, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *