Skip to content
Follow
CMS

How to install Drupal with Nginx on Ubuntu 24.04

Richard
Written by
Richard
May 29, 2024 Updated Jun 20, 2026 6 min read
How to install Drupal with Apache support on Ubuntu 24.04
How to install Drupal with Apache support on Ubuntu 24.04

You install Drupal with Nginx on Ubuntu 24.04 to build a fast and scalable web server.

Drupal is a popular open-source content management system (CMS) known for its flexibility, and Nginx is a high-performance web server celebrated for its efficiency.

This guide shows you how to set up Drupal 10, the latest stable version, with Nginx on the brand-new Ubuntu 24.04 LTS (Noble Numbat).

This combination is perfect for delivering high-traffic websites that demand speed and reliability. Nginx’s asynchronous, event-driven architecture handles concurrent connections better than many alternatives.

⚡ 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.

Install Nginx HTTP server on Ubuntu

Nginx is a popular web server that Drupal needs to run, and installing it on Ubuntu is simple using a quick command in your terminal.

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.

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

Install MariaDB database server on Ubuntu Linux

Drupal needs a database to keep all its information safe, and MariaDB is a good option for this, easily installed on Ubuntu Linux with a simple command.

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.

🐧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.

Create a Drupal database

After setting up MariaDB, you’ll need to create a special database just for Drupal to store its 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.

Finally, we’ll grant the drupaldbuser full access to the drupaldb database.

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

Ensure to replace ‘type_your_password_here‘ with your password.

Install PHP-FPM on Ubuntu Linux

Drupal is built using PHP, so to make sure it runs correctly, you’ll need to install PHP-FPM and some important modules on your Ubuntu Linux system.

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

It’s time to get the Drupal files onto your Ubuntu server and put them in the right place for Nginx to use, which involves downloading the latest version.

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.

Finally, the permissions should be changed to allow the Nginx HTTP server to interact with the files.

🐧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;
}
}

Ensure the highlighted PHP version in the file matches the PHP version installed. When you’re done, save the file.

Then, run the commands below to enable the server block and restart the Nginx server.

🐧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

Making your Drupal site secure with HTTPS is important, and Let’s Encrypt provides free SSL/TLS certificates that work with Nginx to protect your site.

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, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

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 *