Skip to content
Follow
CMS

How to Install Drupal with Nginx on Ubuntu 24.04

Richard
Written by
Richard
May 29, 2024 Updated Sep 15, 2026 7 min read
How to install Drupal with Apache support on Ubuntu 24.04
How to install Drupal with Apache support on Ubuntu 24.04

Installing Drupal with Nginx on Ubuntu 24.04 creates a fast, reliable website powered by open-source tools and a high-speed web server. Drupal acts as your website builder, while Nginx handles incoming visitors quickly and efficiently.

Advertisement

This setup runs Drupal 10 on the Ubuntu 24.04 LTS (Long Term Support) operating system. You get a secure, stable platform that loads pages fast, even when many people visit your site at the same time.

⚡ Quick Answer

Install Nginx using `sudo apt install nginx`, then MariaDB with `sudo apt install mariadb-server`. Create a Drupal database and user in MariaDB, and install PHP-FPM using `apt install php-fpm`. Finally, configure Drupal and Nginx.

Advertisement

Install Nginx HTTP server on Ubuntu

To install Nginx on Ubuntu for your Drupal site, open your terminal and run the commands sudo apt update followed by sudo apt install nginx. This downloads and sets up the Nginx web server so it can serve your website pages to visitors.

To do that, open the Ubuntu terminal and run the commands below to install the Nginx web server.

🐧Bash / Shell
sudo apt update
sudo apt install nginx

Once Nginx is installed, the commands below can start, stop, and enable the Nginx web server to start automatically when your server boots up.

🐧Bash / Shell
sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl enable nginx

You can test that the Nginx HTTP server is running by opening your web browser and browsing to the server’s localhost or IP address.

Advertisement

http://localhost

Welcome to nginx default page Ubuntu
Welcome to nginx default page Ubuntu

When you see the Welcome to nginx! page, it means the Nginx HTTP server is successfully installed.

Additional help on installing Nginx on Ubuntu is in the link below.

How to install Nginx on Ubuntu

Advertisement

Install MariaDB database server on Ubuntu Linux

To install MariaDB on Ubuntu Linux for your Drupal database, run sudo apt install mariadb-server in your terminal. This sets up the database server that stores all your Drupal site content, user accounts, and settings.

To install and use the MariaDB database server, use the instructions below.

Open the Ubuntu terminal and run the commands below to install the MariaDB database server.

🐧Bash / Shell
sudo apt update
sudo apt install mariadb-server

Once the MariaDB database server is installed, use the commands below to stop, start, and enable the MariaDB server to start automatically when the server boots.

Advertisement
🐧Bash / Shell
sudo systemctl stop mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb

Run the following commands to validate and test if the MariaDB database server is installed successfully.

🐧Bash / Shell
sudo mariadb

Once you run the commands above, it will log you onto the MariaDB console and display a message similar to the one below.

💻Code
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 32
Server version: 10.11.2-MariaDB-1 Ubuntu 23.04

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

The message tells you that the server is installed successfully.

Additional help on installing MariaDB.

Advertisement

Create a Drupal database

To create a Drupal database in MariaDB, open the database prompt by running sudo mysql and execute the SQL commands to create a dedicated database and user. This gives Drupal a secure space to store all your application content and data.

This database will store the Drupal application content and data.

We will create a database called drupaldb. We will also create a database user account called drupaldbuser.

The drupaldbuser receives full control over the drupaldb database, allowing drupaldbuser to create, modify, and delete data within the drupaldb database.

Advertisement

All the database steps above can be done using the commands below:

But first, log on to the MariaDB database server:

🐧Bash / Shell
sudo mariadb

Then run the commands below to complete the steps:

💻Code
CREATE DATABASE drupaldb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER drupaldbuser@localhost IDENTIFIED BY 'type_your_password_here';
GRANT ALL ON drupaldb.* TO drupaldbuser@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
⚠️WarningEnsure to replace ‘type_your_password_here‘ with your password.
Advertisement

Install PHP-FPM on Ubuntu Linux

To install PHP-FPM on Ubuntu Linux for Drupal, run sudo apt install php-fpm along with required extensions like php-mysql and php-curl. This allows your server to process Drupal's PHP code and connect properly to the database.

Run the commands below to install PHP-FPM and related modules.

🐧Bash / Shell
sudo apt install php-fpm php-intl php-mysql php-curl php-cli php-zip php-gd php-common php-mbstring php-xml php-opcache php-readline php-sqlite3 php-zip php-apcu

Additional help on installing PHP

How to install PHP on Ubuntu Linux

Download Drupal files

To download Drupal files on your Ubuntu server, use wget to grab the latest release archive from the official site and extract it into your web root folder at /var/www/html. This places the core application files where Nginx can read and serve them.

The command block below will download and create a new Drupal folder in the Nginx root directory.

First, create a Drupal folder in the Nginx root directory.

Please change it to the /tmp directory and download Drupal files. Unzip the file and move the content into the created Drupal folder.

Permissions for Drupal's web root directory **must** be changed so the Nginx HTTP server can read and write files. Set ownership to the `www-data` user and group, the user Nginx typically runs as on Ubuntu 24.04, to grant the necessary access for Drupal to function correctly.

🐧Bash / Shell
sudo mkdir -p /var/www/drupal
cd /tmp/
wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
tar -xvf drupal.tar.gz
sudo mv drupal-*/* /var/www/drupal
sudo chown -R www-data:www-data /var/www/drupal/
sudo chmod -R 755 /var/www/drupal/

Once you have completed all the above steps, continue below to configure the Nginx web server to serve the Drupal content.

Run the commands below to create a Nginx server block file for Drupal.

🐧Bash / Shell
sudo nano /etc/nginx/sites-available/drupal.conf

Then, copy and paste the content block below into the Nginx server block.

🐘PHP
server {
listen 80;
server_name drupal.example.com;
root /var/www/drupal;

index index.php;

location / {
try_files $uri /index.php?$query_string;
}

location @rewrite {
rewrite ^/(.*)$ /index.php?q=$1;
}

location ~ '.php$|^/update.php' {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

location ~* /sites/.*/files/styles/ {
try_files $uri @rewrite;
}

location ~ ^/sites/.*/files/ {
try_files $uri @rewrite;
}

location ~* .(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires max;
log_not_found off;
}
}
⚠️WarningEnsure the highlighted PHP version in the file matches the PHP version installed.

When you're done, save the file.

Enable the Nginx server block for your Drupal site by running the command `sudo ln -s /etc/nginx/sites-available/drupal /etc/nginx/sites-enabled/` and then restart the Nginx server using `sudo systemctl restart nginx`. This ensures Nginx recognizes and serves your new Drupal installation.

🐧Bash / Shell
sudo ln -s /etc/nginx/sites-available/drupal.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx

Setup Let’s Encrypt SSL/TLS for Drupal

To set up Let's Encrypt SSL/TLS for Drupal on Nginx, install the Certbot tool using snap and run sudo certbot --nginx. This automatically generates a free security certificate and updates your Nginx configuration to force secure HTTPS connections.

Please read the post below for additional resources on installing and creating Let’s Encrypt SSL certificates for Nginx.

How to set up Let’s Encrypt SSL certificate for Nginx on Ubuntu Linux

After installing, the Nginx server block file /etc/nginx/sites-available/drupal.conf will automatically be configured with HTTPS, done by the Certbot Nginx plugin.

Once you have restarted the Nginx web server, open your browser and browse to the server hostname or IP address defined in the Nginx server block.

💻Code
http://drupal.example.com

A new Drupal installation wizard will appear. Choose the site's language and continue.

Drupal language selection screen during installation
Drupal language selection screen during installation

Next, select the installation profile.

Drupal installation profile selection interface
Drupal installation profile selection interface

Next, confirm all requirements are met and continue.

Then, type in the database name, username, and password created above.

Database entry configuration for Drupal setup
Database entry configuration for Drupal setup

Finally, set up your site name and create an admin account to login in.

Site configuration settings for Drupal installation
Site configuration settings for Drupal installation

Your new Drupal site should be created and ready to use.

Completion screen of Drupal installation process
Completion screen of Drupal installation process

That should do it!

Conclusion:

  • Setting up a Drupal site with Nginx support on Ubuntu enhances performance and user experience.
  • Nginx's efficient web request handling and high traffic tolerance make it an excellent choice for hosting Drupal websites.
  • The combination of Drupal with Nginx on Ubuntu ensures a secure and reliable web environment, adding value to your projects.
  • Securing the Drupal installation with the Let’s Encrypt SSL/TLS certificate further enhances the website's security and trustworthiness.
  • The detailed steps in this article guide you through seamlessly installing and configuring each component, resulting in a fully functional Drupal site ready for use.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

📚 Related Tutorials

How to Install Nginx on Ubuntu Linux
Ubuntu Linux How to Install Nginx on Ubuntu Linux
How to Install Drupal with Nginx and Cloudflare on Ubuntu
CMS How to Install Drupal with Nginx and Cloudflare on Ubuntu
How to Install GNOME Desktop on Ubuntu 24.04
Ubuntu Linux How to Install GNOME Desktop on Ubuntu 24.04
How to Start, Stop, and Restart Services in Windows 11
Windows How to Start, Stop, and Restart Services in Windows 11

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *