Skip to main content


·1065 words·5 mins· loading · loading · ·
Drupal Nginx Ubuntu Linux Opensource
Table of Contents

Along with WordPress, Drupal is another popular CMS with greater flexibility. Drupal 10 was released on Dec 2022, and it continues to be THE CMS if you plan on some complicated customized work on your website. In this article, we’ll go over step-by-step instructions to install Drupal 10 with Nginx on the latest Ubuntu 22.04 LTS.

1. Prerequisite to Install Drupal 10

I assume you have installed Nginx and properly installed the SSL certificate for your domain. Use the following command to make sure Nginx is properly running.

    sudo systemctl status nginx

2. Install PHP

Like WordPress, Drupal is written in PHP. So you’ll need to install PHP, PHP-FPM and related libraries in order for Drupal to run. Use the following apt command to install them.

    sudo apt update
    sudo apt install php php-mysql
    sudo apt install php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip

As of Mar 2023, the above command will install php8.1 on Ubuntu 22.04. Make sure php-fpm is properly running using systemctl.

    sudo systemctl status php8.1-fpm

If you are still not sure which version was installed, use the following command to find out.

    sudo systemctl status php* | grep fpm.service

3. Install PHP Composer

Some installation guide starts with downloading the Drupal zip file. It’s not wrong, but the Drupal team recommends installing Drupal through composer if possible. According to Concept: Methods for Downloading and Installing the Core Software, “If you are building a site that might use modules with complicated dependencies, you should use Composer to download the core software, because Composer will manage the dependencies properly. “

Use the following lines to download PHP composer.

    php -r "copy('', 'composer-setup.php');"
    php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    php composer-setup.php
    php -r "unlink('composer-setup.php');

Now, you shall have composer.phar in your current directory. Then move it to the bin directory, so we can access it later.

    sudo mv composer.phar /usr/local/bin/composer

If you would like to know more details about the composer, please refer to

4. Install Drupal and Dependencies

Install 7zip or unzip, as they will speed up the installation process.

    sudo apt install 7zip unzip

Go to the directory, where you place the website content. Let’s assume it’s under /var/www/. Please check your Nginx’s default user. It’s usually www-data if you have not changed it.

    cd /var/www/
    sudo -u www-data composer create-project drupal/recommended-project drupal

You shall be able to see the following output if everything works as expected.

Congratulations, you’ve installed the Drupal codebase from the drupal/recommended-project template!

Now, let’s take a look at what we have under the directory drupal.

    ubuntu@myhost:/var/www/ ls composer.json  composer.lock  vendor  web

We’ve got vendor and web directory and composer files. The directory web will be the root of your site. Let’s take a look at it.

    ubuntu@myhost:/var/www/$ ls INSTALL.txt  autoload.php  example.gitignore  modules   robots.txt  themes      web.config    core          index.php          profiles  sites       update.php

It has index.php, robots.txt, and other standard files as in a standard web root directory.

5. Configure Nginx for Drupal

The official Nginx Drupal Recipe shows some age as Drupal 7 and 8 were mentioned there. It’s still a very good source of reference. There are essentially a few things you have to change to bridge Nginx with php-fpm for Drupal. Instead of fastcgi config in the Nginx Drupal Recipe, we’ll just use Nginx default configuration in snippets/fastcgi-php.conf.

    server {
            root /var/www/;
            index index.php;
            # change =404 in try_files to pass the argument to index.php
            # either $args or ?$query_string is fine, as they are the same
            location / {
                    try_files $uri $uri/ /index.php?$args;
            # uncomment those lines shipped with recent Nginx default config
            location ~ \.php$ {
                    include snippets/fastcgi-php.conf;
                    # With php-fpm (or other unix sockets):
                    fastcgi_pass unix:/run/php/php8.1-fpm.sock;

After modifying the Nginx configuration, you’ll always need to restart the Nginx server.

    sudo systemctl restart nginx

6. Install and Configure a Database

Drupal needs a database to store its data, and recommend MySQL, MariaDB, or Percona Server. In this tutorial, we’ll use mariadb.

    sudo apt install mariadb-server mariadb-client
    sudo systemctl status mariadb

It’s a good practice to use the following command to make the installation secure, although it’s not mandatory.


Follow the prompt, and you may choose a root password, remove anonymous users and test the database, etc.

After you verify MariaDB is installed and running successfully, log in it using the password.

    $ mysql -u root -p

Then you are under MariaDB’s prompt. Use the following commands to create a database and username for Drupal. But remember to change the username and password to yours.

    MariaDB [(none)]> CREATE DATABASE db_dp_yourdomain DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
    MariaDB [(none)]> CREATE USER 'dpuser'@'localhost' IDENTIFIED BY 'pwd20230314';
    MariaDB [(none)]> GRANT ALL ON db_dp_yourdomain.* TO 'dpuser'@'localhost';

Then, we need to grant the privilege.

    MariaDB [(none)]> FLUSH PRIVILEGES;

Of course, you can show databases and users to make sure they are there.

You can also verify the user has privileges over the database.

    MariaDB [(none)]> SHOW DATABASES;
    MariaDB [(none)]> SELECT user FROM mysql.user;

You can also verify the user has privileges over the database.

    MariaDB [(none)]> SELECT * FROM mysql.db WHERE Db = 'db_dp_yourdomain'\G;

Finally, we can exit MariaDB.

    MariaDB [(none)]> Exit;

7. Install Drupal 10 Site

Finally here comes the grand finale. In your browser, type in It’ll redirect to install.php.

Initial Drupal Site Installation Screen

Continue to choose the standard installation.

Installation Profile

Similarly, in the “Set up database” give the database, username, and password you just created. If you running the database on the localhost and default port, you do not need to change ‘Advanced Options’.

Database Configuration

Supply site name and site email in “Configure Site”. If you do not have a nice name yet, just put a placeholder and you can always change it in your settings later. Please also write down the username and password somewhere else for your site maintenance account.

Configure Site

Finally, you are ready to see your Drupal site.

8. Conclusion

Obviously, it’s not trivial to install Drupal 10 in your own environment. But since you choose Drupal, you expect to have some customization to your website, right? Knowing the installation process is the first step in enabling you to make your dream website.

What’s the issue you have faced during installation? Please add a comment below.


Hello World
·133 words·1 min· loading · loading
Drupal Openai Chatgpt Linux Opensource Hugo
Hello world!
Installing ownCloud in Docker with Docker Compose
·245 words·2 mins· loading · loading
Docker Owncloud Openai Linux Opensource Chatgpt
In this tutorial, we’ll walk through the steps to install ownCloud in Docker using a Docker Compose file for easy cloud storage and file sharing.
markdown test
·696 words·4 mins· loading · loading
Hugo Opensource Chatgpt Linux Markdown
Features # Support Standard Markdown / CommonMark and GFM(GitHub Flavored Markdown); Full-featured: Real-time Preview, Image (cross-domain) upload, Preformatted text/Code blocks/Tables insert, Code fold, Search replace, Read only, Themes, Multi-languages, L18n, HTML entities, Code syntax highlighting…; Markdown Extras : Support ToC (Table of Contents), Emoji, Task lists, @Links…; Compatible with all major browsers (IE8+), compatible Zepto.