meocuteequas
How to install Drupal 11.1.2 on Ubuntu server 22.04

How to install Drupal 11.1.2 on Ubuntu server 22.04

meocuteequas Jan 6, 2025

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.

Prerequisites

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

Installing Drupal on Ubuntu: A Step-by-Step Guide

First, we need to update the server to the latest version.

sudo apt-get update sudo apt full-upgrade

This command will update the package index and upgrade all installed packages to the latest versions available.

Installing the Apache Web Server

Apache is a popular web server software that’s widely used for hosting websites. To install Apache on Ubuntu on your system server, execute the following command:

sudo apt install apache2

Once the installation is complete, start and enable the Apache service to ensure it runs automatically on system boot:

sudo systemctl start apache2 sudo systemctl enable apache2

To verify that the Apache service is running, check its status with the following command:

sudo systemctl status apache2

If the service is running correctly, you should see a message indicating that Apache is active and running.

Configuring the Firewall

By default, To enable a firewall on your Ubuntu system you can install UFW on Ubuntu system. An Uncomplicated Firewall is a user-friendly configuration tool. To allow incoming traffic on the default Apache port (80), run the following command:

sudo ufw allow http

This will allow incoming HTTP traffic, making your Apache server accessible from outside the local network.

Installing PHP and Database Dependencies for Drupal

In the previous section, we installed the Apache web server and configured the firewall to allow incoming traffic. Now, we’ll focus on installing the PHP and database dependencies required for Drupal.

Drupal requires PHP to function correctly. To install PHP 8.3 with the necessary extensions, execute the following command:

sudo apt install php

Enable the PHP extensions and database support for Drupal:

sudo apt install -y php8.3-pdo php8.3-mysql php8.3-xml php8.3-gd

This installs:

  • php8.3-pdo → Core PDO support
  • php8.3-mysql → MySQL database support
  • php8.3-xml → Required for XML processing
  • php8.3-gd → Required for image processing

Installing the MariaDB Database Server

Drupal uses a database to store its content. We’ll install MariaDB, a drop-in replacement for MySQL.

sudo apt install mariadb-server -y

Since the installation is complete, start and enable the MariaDB service to ensure it runs automatically on system boot:

sudo systemctl start mariadb sudo systemctl enable mariadb

To verify that the MariaDB service is running, check its status with the following command:

sudo systemctl status mariadb

If the service is running correctly, you should see a message indicating that MariaDB is active and running.

Creating a Drupal Database and User

Now, we need to create a database and user for Drupal.

sudo mysql -u root -p

Enter the following commands to create a new database and user:

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

This creates a new database named drupal and a user named drupal with the password drupal. The user is granted all privileges on the drupal database.

Downloading Drupal

To download Drupal, navigate to the default Apache document root:

cd /var/www/html

Download the latest version of Drupal:

sudo wget https://www.drupal.org/download-latest/zip

Next, install unzip and unzip the downloaded file:

sudo apt install unzip -y sudo unzip drupal.zip

Move the extracted files to the Apache document root:

sudo mv drupal-11.1.2/ drupal/

To ensure that Drupal can write to the necessary files and folders, set the correct permissions:

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

This command sets the ownership of the drupal directory and all its contents to the www-data user and group.

Creating an Apache Virtual Host File

To create an Apache virtual host file for Drupal, navigate to the Apache configuration directory:

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

Next, open the file and paste the following configuration:

<VirtualHost *:80> ServerName yourdomain.com DocumentRoot /var/www/html/drupal <Directory /var/www/html/drupal> AllowOverride All </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>

Replace yourdomain.com with your actual domain name then save and close the file. For example, if your domain name is example.com, the file should look like this:

<VirtualHost *:80> ServerName example.com </VirtualHost>

Or if you are not having a domain name, you can use the IP address of the server. For example, if your IP address is 192.168.1.100, the file should look like this:

<VirtualHost *:80> ServerName 192.168.1.100 </VirtualHost>

Enabling the Apache Configuration and Rewrite Module

To enable the Apache configuration and rewrite module, run the following commands:

sudo a2enmod rewrite

Checking the Syntax and Restarting Apache

sudo apachectl configtest sudo systemctl restart apache2

Once the Apache service is restarted, you can complete the Drupal installation by accessing http://yourdomain.com in your web browser. Follow the on-screen instructions to complete the installation

Configure inbound rules for the firewall (if you are using a cloud provider like AWS, Azure, etc.)

If you are using a cloud provider like AWS, Azure, etc., you need to configure the inbound rules for the firewall to allow the HTTP and HTTPS traffic.

Go to the security group and add the following inbound rules:

  • Type: HTTP
  • Port Range: 80
  • Source: 0.0.0.0/0

Save the rules and apply them to the security group. Now you can access the Drupal website from the internet. Remember that you exposed the HTTP port 80 to the internet so you can only access the website using the HTTP protocol. For example, if your domain name is example.com, you can access the website using the following URL: http://example.com

Summary

In this tutorial, we have installed Drupal 11.1.2 on Ubuntu 22.04 server. We have also configured the Apache web server and the MariaDB database server. We have also created a new database and user for Drupal. We have also downloaded and installed Drupal. We have also created an Apache virtual host file for Drupal. We have also enabled the Apache configuration and rewrite module. We have also checked the syntax and restarted the Apache service.


Leave a comment

Responses

You may also like

Pattern 04

Lets work together on your next project

Collaboration is key! Lets join forces and combine our skills to tackle your next project with a powerful energy that guarantees success.