Home Drupal CMS How to Install Drupal CMS in Ubuntu 20.04/22.04

How to Install Drupal CMS in Ubuntu 20.04/22.04

CMS platforms are becoming a norm in the World Wide Web and Drupal is a reputable candidate in this docket. With CMS platforms, content management is easier for all users as all the needed administrative functionalities for managing website content have been met. Therefore, it doesn’t matter whether you are running a small blog site, government site, or a large corporate website.

Drupal is powered by PHP programming language and this article guide will walk us through its installation on Ubuntu 20.04 and Ubuntu 22.04.

Drupal Features

The following are the prominent features of Drupal.

  • It is free and open-source.
  • 30000-plus freely available and downloadable modules.
  • Default-installed support for creating polls, forums, and blogs via modules.
  • 110-plus languages support.
  • Multi-user content editing and multi-site support.
  • Basic features support for creating a comment system, pages, add-ons, RSS feeds, publishing posts, etc.

Prerequisites

Ensure that you are a Sudoer/root user on the Ubuntu system you are using and have a basic understanding of using the Linux terminal/command-line interface.

Installing Apache and PHP in Ubuntu

First, make sure that the Ubuntu system you are using is up-to-date.

$ sudo apt update -y
$ sudo apt upgrade -y

Next, install Apache web server and PHP using the following command.

$ sudo apt install apache2 php libapache2-mod-php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-intl php-mbstring php-curl php-xml php-pear php-tidy php-soap php-bcmath php-xmlrpc
Install Apache and PHP in Ubuntu
Install Apache and PHP in Ubuntu

Installing MySQL in Ubuntu

The next step is to have MySQL or MariaDB database installed and configured on your Ubuntu system.

To install MySQL run:

$ sudo apt install mysql-server

To install MariaDB run:

$ sudo apt install mariadb-server mariadb-client
Install MySQL in Ubuntu
Install MySQL in Ubuntu

After either of the above installations is complete, secure your installed database with the command:

$ sudo mysql_secure_installation
Secure MySQL in Ubuntu
Secure MySQL in Ubuntu

Since Ubuntu systems use Unix_auth_socket_plugin for MySQL/MariaDB, accessing this database might require Sudoer privileges:

$ sudo mysql -u root -p

Create a Drupal user, database, and grant this user the needed database privileges.

MariaDB [(none)]> CREATE USER drupal@localhost IDENTIFIED BY "Your_drupal_user_password";
MariaDB [(none)]> CREATE DATABASE drupal;
MariaDB [(none)]> GRANT ALL ON drupal.* TO drupal@localhost;
MariaDB [(none)]> FLUSH PRIVILEGES; 
MariaDB [(none)]> EXIT;
Create Drupal Database
Create Drupal Database

Installing Drupal in Ubuntu

The official Ubuntu repository does not have Drupal as a package. Therefore, downloading Drupal from its website via the wget command ensures we get its latest version release.

$ wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
Download Drupal Ubuntu
Download Drupal Ubuntu

Extract drupal and move it to /var/www/html directory and set the appropriate permissions.

$ tar -xvf drupal.tar.gz
$ sudo mv drupal-9.3.7 /var/www/html/drupal 
$ sudo chown -R www-data:www-data /var/www/html/drupal/
$ sudo chmod -R 755 /var/www/html/drupal/ 

Create Drupal Apache Virtual Host in Ubuntu

Create a virtual host file for Drupal and implement a similar configuration to the one below.

$ sudo nano /etc/apache2/sites-available/drupal.conf

Add the following virtual host configuration.

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/drupal/
    ServerName linuxshelltips.lan.network
    ServerAlias www.linuxshelltips.lan.network
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/html/drupal/>
            Options FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>

    <Directory /var/www/html/>
            RewriteEngine On
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$  index.php?q=$1  [LxQSA]
    </Directory>
</VirtualHost>

Next, enable the mod_rewrite rule.

$ sudo a2ensite drupal.conf
$ sudo a2enmod rewrite 
Enable Mod_Rewrite for Drupal
Enable Mod_Rewrite for Drupal

Restart Apache web server and make sure it is running:

$ sudo systemctl restart apache2
$ sudo systemctl status apache2
Check Apache Status in Ubuntu
Check Apache Status in Ubuntu

Installing Drupal from Web Browser

The final setup of Drupal will be through your web browser based on the domain name you specified in drupal.conf file.

http://linuxshelltips.lan.network

Choose a preferred language.

Choose Drupal Language
Choose Drupal Language

Choose the installation standard profile.

Choose Drupal Installation
Choose Drupal Installation

Fill in your database details.

Drupal Database Settings
Drupal Database Settings

The above step might take some time to complete, therefore, be patient. Afterward, drupal site installation will automatically begin.

Drupal Installation in Ubuntu
Drupal Installation in Ubuntu

This step will also take some time before completing. The final step will be to fill in your site’s details like site name, and email address.

Configure Drupal Website
Configure Drupal Website

You should then be greeted with the following screen capture:

Running Drupal Website
Running Drupal Website

From here, you can explore and manage your web content through this extensive Drupal CMS.

With Drupal, you do not just have any CMS. You have an extensive and scalable platform for managing both users and web content you hope to create in a flexible and memorable user interface.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.