How to Install Drupal on Debian 12

how to install drupal on debian 12

Drupal is an open-source content management system written in PHP. It offers sophisticated API for developers, hundreds of themes, and distributions that allow users to create a complex website in a couple of steps.

Also, there are some main features such as user account registration, menu management, page layout customization, and many more. The data is stored in a MariaDB (MySQL) database system. In this blog post, we will install Drupal with the LAMP stack.

Installing Drupal with the LAMP stack is a straightforward process that may take up to 20 minutes. Let’s get started!


  • A server with Debian 12 as OS
  • User privileges: root or non-root user with sudo privileges

Step 1. Update the System

Before we start with LAMP stack installation, 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

First of the stack will be the Apache web server. To install Apache execute the following command:

sudo apt install apache2 -y

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@host:~# sudo systemctl status apache2 
● apache2.service - The Apache HTTP Server 
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: enabled) 
Active: active (running) since Tue 2023-09-05 02:45:15 CDT; 17s ago 
Main PID: 113104 (apache2) Tasks: 55 (limit: 4644) 
Memory: 8.9M 
CPU: 72ms 
CGroup: /system.slice/apache2.service ├─113104 /usr/sbin/apache2 -k start ├─113105 /usr/sbin/apache2 -k start └─113106 /usr/sbin/apache2 -k start

Step 3. Install PHP8.2

Next is the installation of the PHP8.2. To install PHP8.2 execute the following command:

sudo apt-get install php8.2 php8.2-cli php8.2-common php8.2-imap php8.2-redis php8.2-snmp php8.2-xml php8.2-mysqli php8.2-zip php8.2-mbstring php8.2-curl php8.2-gd libapache2-mod-php -y

Once installed, check the PHP version with the following command: php -v

root@host:~# php -v 
Created directory: /var/lib/snmp/cert_indexes 
PHP 8.2.7 (cli) (built: Jun 9 2023 19:37:27) (NTS) 
Copyright (c) The PHP Group 
Zend Engine v4.2.7, Copyright (c) Zend Technologies 
with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies

Step 4. Install MariaDB database service

The last of the LAMP stack is the MariaDB database service. To install it, execute the following command:

sudo apt install mariadb-server -y

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.11.3 database server 
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enabled) 
Active: active (running) since Wed 2023-09-06 04:29:29 CDT; 21s ago 
Docs: man:mariadbd(8) 
Main PID: 6216 (mariadbd) 
Status: "Taking your SQL requests now..." 
Tasks: 16 (limit: 4644) 
Memory: 192.7M 
CPU: 760ms 
CGroup: /system.slice/mariadb.service └─6216 /usr/sbin/mariadbd

Step 5. Create a Drupal database and user

Next, we need to create a Drupal database, the 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

First, go into the Document root of the Apache web server:

cd /var/www/html

Download the latest Drupal with the following command:

mv drupal-10.1.2/ 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.

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer

Now just $43 .99

<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.

a2dissite 000-default.conf 

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, restartd the Apache service.

systemctl restart apache2

Once the Apache service is restarted, you can finish the Drupal installation at While finishing the Drupal installation, you will need to fill in the database info you created before. Also, you will set up your administrator credentials, and your website will be successfully created.

If you find this setup difficult, please contact our technical support. We are available 24/7 and will help you with your Drupal configuration.

If you liked this post about installing Drupal on Debian 12, please share it with your friends on social networks or simply leave a reply below.

Leave a Comment