1. Home
  2. Cloud and Servers
  3. Virtual Servers (VPS)
  4. Installing Drupal on Ubuntu 20.04 with LEMP

Installing Drupal on Ubuntu 20.04 with LEMP

If you have on your Virtual server (VPS) installed LEMP (Linux, Nginx, MySQL and PHP) and security certificate, you can finally start with the website itself. Not everyone can create a website from scratch only with programming languages like HTML, JavaScript or PHP, and for that we have content management systems (CMS).

One of the most popular and mostly used CMS worldwide is Drupal. It is a system that will supremely ease the process of creating a website. Web with unique design and content can be created without programming, you will simply click everything in the browser.

Set up web server Nginx

For Drupal to be able to display articles via permalinks in a nicer forma (instead of /index.php/hello-world/ at the end of URL there will be/hello-world/), we need to edit the configuration file on the Nginx server:

sudo nano  /etc/nginx/sites-available/default

In the configuration file locate a line server { with following commentary # SSL configuration under the section location / { edit the directives try_files as follows:

try_files $uri $uri/ /index.php?$query_string =404;

Under the directive ssl_dhparam enter additional lines:

proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
fastcgi_send_timeout 600;
fastcgi_read_timeout 600;

Save the configuration file Ctrl + X and then press the button y and confirm with Enter.

Restart the web server Nginx for the change in the configuration file to take effect:

sudo systemctl restart nginx

More thorough setting of the web server Nginx for Drupal can be found in the official configuration Nginx on the address https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/.

Set up PHP

Firstly it is necessary to secure the updates of all packages. Install updated software in two commands in one go:

sudo apt update && sudo apt upgrade

If the system finds the updated packages, it will ask you whether you want to install them:

Do you want to continue? [Y/n]

Press the y if you want to proceed to update or press n, if you do not want to update them. Then press the Enter key.

For correct functionality of Drupal as a whole, modules are required, which are not included in the common PHP installation. We can install them via this command:

sudo apt install php-curl php-gd php-imagick php-mbstring php-xml php-zip

System will ask if you want to install the modules:

Do you want to continue? [Y/n]

Press the y if you want to proceed with the installation or press n, if you do not want to install them. Then press the Enter key.

Check for the PHP version, that is installed:

php -v

so we would be able in the correct configuration file php.ini

sudo nano /etc/php/7.4/fpm/php.ini

set the following lines:

short_open_tag = On
cgi.fix_pathinfo = 0
max_execution_time = 600
max_input_time = 600
default_socket_timeout = 600
memory_limit = 256M
upload_max_filesize = 100M
post_max_size = 100M
date.timezone = Europe/Bratislava

Save the configuration file Ctrl + X and then press the button y and confirm with Enter.

Restart the PHP version for the changes in the configuration to take effect:

sudo systemctl restart php7.4-fpm

Creating user and database in MySQL

Drupal text details like articles or comment are stored into database. So the Drupal would be able safely communicate with MySQL server, we need to create a new user with limited rights (we will not use the root user). Start the communication with database server MySQL:

sudo mysql

Create a user (in this example tibor), that we will assign a strong password (in this example This.1s.Strong:Password. In the password use at least 8 characters – lower and upper case, numbers and special symbols like dot, comma, colon, at, question mark , exclamation mark

create user 'tibor'@'localhost' identified by 'This.1s.Strong:Password';

create a database called drupal:

create database drupal;

and set for user tibor all right with the database drupal as follows:

grant all privileges on drupal.* to 'tibor'@'localhost';
flush privileges;

End the work with MySQL server:

exit

Drupal installation

Before the Drupal installation erase all content from the html directory:

sudo rm -rf /var/www/html/*

Go to the directory html, where the Drupal will be installed:

cd /var/www/html

Download (first line) and unpack (second line) and move (third line) all necessary files and directories of the current version of Drupal.

Characters x.x.x are to be replaced with the version from the unpacked directory (here 9.0.1).

sudo wget https://www.drupal.org/download-latest/tar.gz
sudo tar -zxvf tar.gz
sudo mv drupal-x.x.x/* ./

Delete unnecessary directories and files (first line) and then set the ownership and rights to files and directories (last two lines):

sudo rm -rf drupal-9.0.1 tar.gz
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html

Additional settings can be done via browser on the address of the server (in this example vps.active24.cz) in these steps:

  1. Choose language > English > Save and continue
  2. Choose profile > Standard > Save and continue
  3. Set up database > Database name drupal
  4. Set up database > User name: tibor
  5. Set up database > Password: This.1s.Strong:Password
  6. Set up database > Save and continue
  7. Configure site > Site name: Drupal
  8. Configure site > Site email address: meno.priezvisko@domena.sk
  9. Configure site > Username: tibor
  10. Configure site > Password and Confirm password: This.1s.Strong:Password
  11. Configure site > Default country: Your country
  12. Configure site > Receive email notifications: uncheck
  13. Configure site > Save and continue

After the successful installation you will see the default main page with “Welcome to Drupal”:

Summary

We have set the webserver Nginx, installed missing modules for PHP and set some variables in PHP and created a new user for database so we could then install the Drupal CMS. Part of the installation process was via console (Linux shell bash) and another part was in web browser. All other Drupal setting can be configured in the graphic interface in the web browser. From the web browser we can also realize installation, updates and adding new content.

Updated on January 3, 2025

Was this article helpful?

Related Articles