How to Install Drupal on Debian 12

Drupal is a Content Management System (CMS) to maintain and publish an internet website. It's an open-source content management system (CMS) with a large, supportive community. It's used by millions of people and organizations around the globe to build and maintain their websites.

Update the system.

apt update -y 

apt upgrade -y

Install sudo command using below command,

apt install sudo

NOTE: sudo run programs with the security privileges of another user recommanded use if you are non-root user.

Install MariaDB database server

apt install -y mariadb-server mariadb-client

Secure your database server by setting a root password, disabling root remote logins, and removing test databases.

mysql_secure_installation

Output:

root@vps:~# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

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!

Check that you can login to the database as a root user with a password set

mysql -u root -p

Output:

root@vps:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 58
Server version: 10.3.31-MariaDB-0+deb10u1 Debian 10

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)]>

Create Database for Drupal

mysql -u root -p
CREATE DATABASE drupal;
CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost';
FLUSH PRIVILEGES;
\q

Replace the StrongPassword with unique,safe and strong password

Output:

root@vps:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 58
Server version: 10.3.31-MariaDB-0+deb10u1 Debian 10

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)]> CREATE DATABASE drupal;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]>  CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'StrongPassword';
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost'
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> \q
Bye

Install PHP

apt install php php-{cli,fpm,json,common,mysql,zip,gd,intl,mbstring,curl,xml,pear,tidy,soap,bcmath,xmlrpc}

Output:

root@vps:~# sudo apt install php php-{cli,fpm,json,common,mysql,zip,gd,intl,mbstring,curl,xml,pear,tidy,soap,bcmath,xmlrpc}
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils fontconfig-config fonts-dejavu-core libapache2-mod-php8.2 libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap libfontconfig1 libgd3 libjansson4 libjbig0 libjpeg-turbo8 libjpeg8 liblua5.2-0 libonig5
  libtidy5deb1 libtiff5 libwebp6 libxmlrpc-epi0 libxpm4 libzip5 php8.2 php8.2-bcmath php8.2-cli php8.2-common php8.2-curl php8.2-fpm
  php8.2-gd php8.2-intl php8.2-json php8.2-bstring php8.2-mysql php8.2-opcache php8.2-readline php8.2-soap php8.2-tidy php8.2-xml
  php8.2-xmlrpc php8.2-zip ssl-cert
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser libgd-tools openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils fontconfig-config fonts-dejavu-core libapache2-mod-php8.2libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap libfontconfig1 libgd3 libjansson4 libjbig0 libjpeg-turbo8 libjpeg8 liblua5.2-0 libonig5
  libtidy5deb1 libtiff5 libwebp6 libxmlrpc-epi0 libxpm4 libzip5 php php-bcmath php-cli php-common php-curl php-fpm php-gd php-intl
  php-json php-mbstring php-mysql php-pear php-soap php-tidy php-xml php-xmlrpc php-zip php8.2 php8.2-bcmath php8.2-cli php8.2-common
  php8.2-curl php8.2-fpm php8.2-gd php8.2-intl php8.2-json php8.2-mbstring php8.2-mysql php8.2-opcache php8.2readline php8.2-soap
  php8.2-tidy php8.2-xml php8.2-xmlrpc php8.2-zip ssl-cert

Install Apache WebServer

apt install apache2 libapache2-mod-php

Output:

root@vps:~# apt install apache2 libapache2-mod-php
Reading package lists... Done
Building dependency tree
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils libapache2-mod-php7.3 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
libbrotli1 libjansson4 liblua5.2-0 ssl-cert
Suggested packages:
 apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php libapache2-mod-php7.3 libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 libjansson4 liblua5.2-0 ssl-cert
0 upgraded, 14 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,995 kB of archives.
After this operation, 13.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Update PHP Timezone and Memory Limit.

vi /etc/php/*/apache2/php.ini
memory_limit = 256
date.timezone = America

Download the Latest Version of Drupal and extract it on Debian 10

wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
tar xvf drupal.tar.gz
mv drupal-*/  /var/www/html/drupal

Update ownership for the drupal directory to Apache user and group

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

Configure Apache Web Server for Drupal.

Create a configuration file for Drupal

vi /etc/apache2/sites-available/drupal.conf

Add the following content,

Replace example.com with your actual domain name.

<VirtualHost *:80>
     ServerName mysite.com
     ServerAlias www.example.com
     ServerAdmin admin@example.com
     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]
   </Directory>
</VirtualHost>

Configure and Enable Website using below commands,

apachectl -t
a2dismod mpm_event
a2enmod mpm_prefork
a2enmod php7.*
a2enmod rewrite
a2ensite drupal.conf
systemctl restart apache2

Check and Install Drupal on Deian from the browser.

Access the Drupal configuration page by using http://example.com

Replace example.com with your actual domain.

images

Select an installation profile.

images

Set Database Configure for Drupal.

images

Wait for the installation to complete,

images

Configure your site,

images

You’ll get to the Drupal dashboard in a few,

images

Done.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS