Tag Archives: Drupal

Drupal 11 on Ubuntu 24.04

How to Install Drupal on Ubuntu 24.04

Drupal is an open-source content management system (CMS) used for building and managing websites and web applications. It is highly flexible and customizable, making it suitable for a wide range of web projects, from simple blogs to complex enterprise websites.

It is used by a wide range of organizations, including educational institutions, non-profits, businesses, and government agencies, to build websites that require robust content management, high security, and flexibility.

In this tutorial, we will show you how to install Drupal on your Ubuntu 24.04 OS.

Step 1: Update Operating System

Update your Ubuntu 24.04 operating system to make sure all existing packages are up to date:

# apt update && apt upgrade -y

Step 2: Install Nginx webserver

You can install Nginx via apt package manager by executing the following command.

# apt install nginx

You can start the Nginx service and configure it to run on startup by entering the following commands:

# systemctl start nginx
# systemctl enable nginx

Verify the status of the Nginx service using systemctl status command:

# systemctl status nginx

Output:

● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: active (running)
       Docs: man:nginx(8)
   Main PID: 10412 (nginx)
      Tasks: 2 (limit: 2218)
     Memory: 1.7M (peak: 1.9M)
        CPU: 23ms
     CGroup: /system.slice/nginx.service
             ├─10412 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─10413 "nginx: worker process"

Step 3: Install PHP and PHP extensions for Drupal

By default, Ubuntu 24.04 comes with PHP version 8.3.  You can install PHP and other supporting packages using the following command:

# apt install php php-{opcache,gd,curl,mysqlnd,intl,json,ldap,mbstring,mysqlnd,xml,zip}

Verify if PHP is installed.

php -v
Output:
PHP 8.3.6 (cli) (built: Jun 13 2024 15:23:20) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies

Step 4: Install MySQL and create a database

You can install the MySQL server with the following command:

# apt install mysql-server

Start the database server daemon, and also enable it to start automatically at the next boot with the following commands:

# systemctl start mysql
# systemctl enable mysql

Verify the status of the MySQL service using systemctl status command:

# systemctl status mysql

Output:

● mysql.service - MySQL Community Server
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: active (running)
    Process: 24565 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 24574 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 2218)
     Memory: 362.8M (peak: 379.1M)
        CPU: 1.160s
     CGroup: /system.slice/mysql.service
             └─24574 /usr/sbin/mysqld

By default, MySQL is not hardened. You can secure MySQL using the mysql_secure_installation script.

# mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] Y
- Remove anonymous users? [Y/n] Y
- Disallow root login remotely? [Y/n] Y
- Remove test database and access to it? [Y/n] Y
- Reload privilege tables now? [Y/n] Y

Now run the command below to log in to the MySQL shell.

# mysql -u root -p

Once you are logged in to your database server you need to create a database for the Drupal installation:

mysql> CREATE DATABASE drupaldb;
mysql> CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'Str0ngP@ss';
mysql> GRANT ALL PRIVILEGES ON drupaldb. * TO 'drupaluser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> exit;

Step 5: Download Drupal

The latest version of Drupal is available to download from their website. You can download it with the following command:

# wget https://ftp.drupal.org/files/projects/drupal-11.0.0.zip

Extract file into the folder /var/www/ with the following command:

# unzip drupal-11.0.0.zip -d /var/www/

Rename it to make it simpler:

# mv /var/www/drupal-11.0.0/ /var/www/drupal

Enable permission for the Nginx webserver user to access the files:

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

Step 6: Configure Nginx for Drupal

Create a new Nginx virtual host configuration file:

# nano /etc/nginx/conf.d/drupal.conf

Paste the content as shown below:

server {
  listen 80;
  server_name your-domain.com www.your-domain.com;
  root /var/www/drupal;
  index index.php index.html;
  charset utf-8;
  location / {
    try_files $uri $uri/ /index.php?$args;
  }
  location ~ .php$ {
    fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

Remember to replace your-domain.com with the domain name of your server.

Save and exit the configuration file.

To implement the changes, restart Nginx webserver:

# systemctl restart nginx

Step 7: Access Drupal Web Interface

Open your web browser and type the URL https://your-domain.com. You should see the Drupal installation page.

Choose your preferred language and hit Save and continue. You will get the following screen:

Choose Standard and hit Save and continue.

Fill in your database settings and hit Save and continue.

Then fill in some basic information about your site and then hit Save and continue.

You will get the dashboard in the following screen:

Installation of Drupal has been completed. Now revert the permissions for the settings.php file:

# chmod 644 /var/www/html/drupal/sites/default/settings.php

Comments and Conclusion

That’s it. You have successfully installed Drupal on Ubuntu 24.04 OS.

For additional help or useful information, we recommend you to check  the official Drupal documentation.

If you have any questions please leave a comment below.

How to Install Drupal 9 on Ubuntu 22.04

Drupal is an open-source and popular content management tool that is the foundation of many websites across the internet. It has great standard features, like easy content authoring, reliable performance, and excellent security. Flexibility and modularity are some of the core principles that set it apart from the rest.

In this tutorial, we will show you how to install Drupal 9 on your Ubuntu 22.04 OS.

Step 1: Update Operating System

Update your Ubuntu 22.04 operating system to make sure all existing packages are up to date:

$ sudo apt update && sudo apt upgrade -y

Step 2: Install Apache webserver

You can install Apache via apt package manager by executing the following command.

$ sudo apt install apache2

You can start the Apache service and configure it to run on startup by entering the following commands:

$ sudo systemctl start apache2
$ sudo systemctl enable apache2

Verify the status of the Apache service using systemctl status command:

$ sudo systemctl status apache2

Output:

● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 3170 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 3174 (apache2)
      Tasks: 12 (limit: 2200)
     Memory: 246.8M
        CPU: 18.104s
     CGroup: /system.slice/apache2.service
             ├─3174 /usr/sbin/apache2 -k start
             ├─3175 /usr/sbin/apache2 -k start
             ├─3176 /usr/sbin/apache2 -k start

You can test to make sure everything is working correctly by navigating to:

http://your-IP-address

If everything is configured properly, you should be greeted by the default Apache2 Page, as seen below.

Step 3: Install PHP and PHP extensions for Drupal 9

By default, Ubuntu 22.04 comes with PHP version 8.1.  You can install PHP and other supporting packages using the following command:

$ sudo apt install php libapache2-mod-php php-dev php-bcmath php-intl php-soap php-zip php-curl php-mbstring php-mysql php-gd php-xml

Verify if PHP is installed.

php -v
Output:
PHP 8.1.6 (cli) (built: May 17 2022 16:46:54) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
with Zend OPcache v8.1.6, Copyright (c), by Zend Technologies

Step 4: Install MySQL and create a database

You can install MySQL with the following command:

$ sudo apt install mysql-server

Start the database server daemon, and also enable it to start automatically at the next boot with the following commands:

$ systemctl start mysql
$ systemctl enable mysql

Verify the status of the MySQL service using systemctl status command:

$ sudo systemctl status mysql

Output:

● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running)
    Process: 832 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 1235 (mysqld)
     Status: "Server is operational"
      Tasks: 46 (limit: 2200)
     Memory: 582.6M
        CPU: 1min 11.087s
     CGroup: /system.slice/mysql.service
             └─1235 /usr/sbin/mysqld

Once the database server is installed, log into the MariaDB prompt:

$ sudo  mysql -u root

To create a database, database user, and grant all privileges to the database user run the following commands:

mysql> CREATE DATABASE drupal;
mysql> CREATE USER 'drupal_user'@'localhost' IDENTIFIED BY 'Drupal_Passw0rd!';
mysql> GRANT ALL ON drupal.* TO 'drupal_user'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT

Step 5: Download Drupal 9

We will now download Drupal 9 from the Drupal Official site.

Use the following command to download Drupal 9:

$ sudo wget https://ftp.drupal.org/files/projects/drupal-9.3.13.zip

Extract file into the folder /var/www/html/ with the following command:

$ sudo apt -y install unzip 
$ sudo unzip drupal-9.3.13.zip -d /var/www/html/

To make things simpler, rename the extracted directory drupal-9.3.13 to just drupal:

$ sudo mv /var/www/html/drupal-9.3.13/ /var/www/html/drupal/

Enable permission for the Apache webserver user to access the files,

$ sudo chown -R www-data:www-data /var/www/html/drupal/

Step 6: Configure Apache Web Server for Drupal 9

Navigate to /etc/apache2/sites-available directory and run the following command to create a configuration file for your installation:

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

Add the following content:

<VirtualHost *:80>

ServerAdmin webmaster@your-domain.com

ServerName your-domain.com
ServerAlias www.your-domain.com
DocumentRoot /var/www/html/drupal

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

ErrorLog ${APACHE_LOG_DIR}/your-domain.com_error.log
CustomLog ${APACHE_LOG_DIR}/your-domain.com_access.log combined

</VirtualHost>

Save the file and Exit.

Enable the Drupal 9 virtual host:

$ sudo a2ensite drupal.conf

After that, restart the Apache web server.

$ sudo systemctl restart apache2

Step 7: Access Drupal 9 Web Installer

Open your browser type your domain e.g http://your-domain.com  and complete the required steps to finish the installation.

Choose your preferred language and hit Save and continue, you will get the following screen:

Choose Standard and hit Save and continue. You will get the following screen:

Fill in your database settings and hit Save and continue.

Fill in some basic information about your site and then hit Save and continue. You will get the dashboard in the following screen:

Installation of Drupal has been completed. Now revert the permissions for the settings.php file:

$ sudo chmod 644 /var/www/html/drupal/sites/default/settings.php

Comments and Conclusion

That’s it. You have successfully installed Drupal 9 on Ubuntu 22.04

If you have any questions please leave a comment below.