Rank #1 on Google Maps
India English
Kenya English
United Kingdom English
South Africa English
Nigeria English
United States English
United States Español
Indonesia English
Bangladesh English
Egypt العربية
Tanzania English
Ethiopia English
Uganda English
Congo - Kinshasa English
Ghana English
Côte d’Ivoire English
Zambia English
Cameroon English
Rwanda English
Germany Deutsch
France Français
Spain Català
Spain Español
Italy Italiano
Russia Русский
Japan English
Brazil Português
Brazil Português
Mexico Español
Philippines English
Pakistan English
Türkiye Türkçe
Vietnam English
Thailand English
South Korea English
Australia English
China 中文
Somalia English
Canada English
Canada Français
Netherlands Nederlands

How to Install Drupal on a VPS (Ubuntu 24.04, Nginx, MariaDB, Composer)

Buy domains, business emails, hosting, VPS and more: Get Started

Cheapest Domains in Kenya

Register a .co.ke domain for Kshs 299 for the first year. Renewal: Kshs 1,500 per year.

.COM registration: Kshs 1,200 for the first year. Renewal: Kshs 1,700 per year.

You just logged in to a brand-new VPS. The cursor blinks. Nothing is installed, and no site exists yet.

This guide takes you from that empty prompt to a live Drupal site on HTTPS. You will install Nginx, PHP-FPM, MariaDB, and Drupal 11 with Composer. Each step ends with a quick check, so you catch problems early.

The guide is written for Ubuntu 24.04 LTS and Drupal 11.4, and was last updated in November 2026. It suits anyone comfortable with SSH. If you want a one-click installer or managed Drupal hosting, this is not the right guide.

What You Need Before You Install Drupal on a VPS

Check these basics first. They save you a restart later.

  • A VPS running Ubuntu 24.04 LTS, with root or sudo access over SSH.
  • At least 2 GB of RAM and 2 vCPUs for a comfortable install.
  • A domain name whose A record already points to your server’s IP address.

Smaller servers can still run Drupal. However, Composer may run short of memory on 1 GB.

Server and software requirements

Drupal 11 sets firm minimums for PHP, the database, and Composer. The table also shows what changes in Drupal 12.

ComponentDrupal 11Drupal 12
PHP8.3 or newer8.5
MariaDB10.6 or newer10.11 or newer
MySQL8.0 or newer8.0 or newer
Composer2.7.0 or newerLatest 2.x (2.9.3 recommended)
Web serverNginx or Apache 2.4.7+Nginx or Apache 2.4.7+

Ubuntu 24.04 ships PHP 8.3 and MariaDB 10.11 in its default repositories. So Drupal 11 installs without third-party repositories. You can confirm the latest numbers on the official Drupal system requirements page.

Which Drupal version to install right now

  • Drupal 11.4 is the current stable line, with security coverage until April 2027.
  • Drupal 11.5 and Drupal 12.0 are scheduled for the week of December 7, 2026.
  • Sites must run Drupal 11.4 or newer before they can update to Drupal 12.
  • This guide installs Drupal 11. The steps should stay the same for 11.5.

Planning for Drupal 12? It requires PHP 8.5 and MariaDB 10.11 or newer. Ubuntu 24.04 ships PHP 8.3. You would need an extra PHP repository or an OS image with PHP 8.5. Check the PHP version your server offers before you commit.

Step 1: Prepare Your VPS for Drupal

ssh root@YOUR_SERVER_IP

apt update && apt upgrade -y

reboot

First, connect to the server and bring every package up to date.

ssh root@YOUR_SERVER_IP

apt update && apt upgrade -y

reboot

Reconnect once the server restarts. Then create a regular user so you stop working as root.

adduser deploy

usermod -aG sudo deploy

rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy

The last command copies your SSH keys to the new user. If your provider gave you a password instead of a key, run ssh-copy-id deploy@YOUR_SERVER_IP from your own computer.

Log out, then log back in as deploy. Next, turn on the firewall. Allow SSH first, or you will lock yourself out.

sudo ufw allow OpenSSH

sudo ufw allow 80/tcp

sudo ufw allow 443/tcp

sudo ufw enable

Checkpoint: Run sudo ufw status. It should list OpenSSH, 80/tcp, and 443/tcp as allowed. Then run getent hosts example.com and confirm it returns your server’s IP address.

Step 2: Install Nginx, PHP-FPM, and the Required PHP Extensions (LEMP Stack)

sudo apt install -y nginx
sudo apt install -y curl unzip git php8.3-fpm php8.3-cli php8.3-mysql \

  php8.3-gd php8.3-xml php8.3-mbstring php8.3-curl php8.3-zip php8.3-opcache

Start with the web server.

sudo apt install -y nginx

Open your domain in a browser. You should see the default Nginx welcome page. If you do not, recheck your DNS record and firewall rules.

Next, install PHP 8.3 with PHP-FPM and all the extensions Drupal needs.

sudo apt install -y curl unzip git php8.3-fpm php8.3-cli php8.3-mysql \

  php8.3-gd php8.3-xml php8.3-mbstring php8.3-curl php8.3-zip php8.3-opcache

Drupal’s defaults are tight for real sites. So raise three PHP values with a small override file.

sudo tee /etc/php/8.3/fpm/conf.d/99-drupal.ini > /dev/null <<'EOF'

memory_limit = 256M

upload_max_filesize = 64M

post_max_size = 64M

EOF

sudo systemctl restart php8.3-fpm

Checkpoint: php -v should report PHP 8.3.x. Also run systemctl is-active nginx php8.3-fpm. Both lines should read active.

Step 3: Create the MariaDB Database and User for Drupal

Install MariaDB and run its security script.

sudo apt install -y mariadb-server

sudo mysql_secure_installation

Answer the prompts to remove anonymous users and the test database. Then generate a strong password for Drupal’s database user.

openssl rand -base64 24

Copy that password somewhere safe. You will need it in the installer. Now open the MariaDB shell and create the database.

sudo mariadb

CREATE DATABASE drupal CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'PASTE_YOUR_PASSWORD_HERE';

GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost';

FLUSH PRIVILEGES;

EXIT;

The utf8mb4 character set lets Drupal store emoji and every language correctly. The new user can only touch the Drupal database. Never reuse the MariaDB root password here.

Checkpoint: Prove the grant works by logging in as the new user.

mariadb -u drupal -p drupal -e "SELECT 1;"

You should see a small table with the number 1 on it.

Step 4: Install Drupal with Composer

cd ~

curl -sS https://getcomposer.org/installer -o composer-setup.php

php composer-setup.php --install-dir=/usr/local/bin --filename=composer

rm composer-setup.php

composer --version

First, install Composer. The official installer always gives you the current release.

cd ~

curl -sS https://getcomposer.org/installer -o composer-setup.php

php composer-setup.php --install-dir=/usr/local/bin --filename=composer

rm composer-setup.php

composer --version

The version must be 2.7.0 or newer. For production servers, verify the installer checksum first. The steps are on the Composer download page.

Now create the project folder and grant your user ownership of it. Composer should never run as root.

sudo mkdir -p /var/www/drupal

sudo chown $USER:$USER /var/www/drupal

cd /var/www/drupal

composer create-project drupal/recommended-project:^11

Composer downloads Drupal core and every dependency. Expect a few minutes on a small server.

Look at the result with ls. You should see three folders: web, vendor, and recipes. The web folder holds the public files. Everything else stays outside it on purpose. As a result, visitors can never load your Composer files or libraries directly.

Composer or the downloaded archive?

Use Composer. The Drupal.org archive works, but it makes updates and module installs more difficult. Composer tracks every dependency, so one command updates the whole stack. Drupal’s own documentation recommends this route.

Checkpoint: Run ls /var/www/drupal/web/core/install.php. The file should exist, and /var/www/drupal/vendor should sit next to web.

Step 5: Configure Nginx to Serve Drupal

sudo ln -s /etc/nginx/sites-available/drupal /etc/nginx/sites-enabled/

sudo rm /etc/nginx/sites-enabled/default

sudo nginx -t

sudo systemctl reload nginx

Nginx needs a server block that points to the web folder. Create the file.

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

Paste in the config below. Replace example.com with your domain.

server {

    listen 80;

    listen [::]:80;

    server_name example.com www.example.com;

    root /var/www/drupal/web;

    index index.php;

    client_max_body_size 64M;

    location = /favicon.ico { log_not_found off; access_log off; }

    location = /robots.txt  { allow all; log_not_found off; access_log off; }

    location ~ \..*/.*\.php$ { return 403; }

    location ~ ^/sites/.*/private/ { return 403; }

    location ~ ^/sites/[^/]+/files/.*\.php$ { deny all; }

    location ~* ^/.well-known/ { allow all; }

    location ~ (^|/)\. { return 403; }

    location / {

        try_files $uri /index.php?$query_string;

    }

    location @rewrite {

        rewrite ^ /index.php;

    }

    location ~ '\.php$|^/update.php' {

        fastcgi_split_path_info ^(.+?\.php)(|/.*)$;

        try_files $fastcgi_script_name =404;

        include fastcgi_params;

        fastcgi_param HTTP_PROXY "";

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_param PATH_INFO $fastcgi_path_info;

        fastcgi_param QUERY_STRING $query_string;

        fastcgi_intercept_errors on;

        fastcgi_pass unix:/run/php/php8.3-fpm.sock;

    }

    location ~ ^/sites/.*/files/styles/ {

        try_files $uri @rewrite;

    }

    location ~ ^(/[a-z\-]+)?/system/files/ {

        try_files $uri /index.php?$query_string;

    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|webp|woff2?)$ {

        try_files $uri @rewrite;

        expires max;

        log_not_found off;

    }

}

Here is what the main lines do:

  • root points to the web folder, never the project root.
  • try_files passes unknown URLs to index.php, which gives you clean URLs.
  • The PHP block sends .php files to PHP-FPM through its socket.
  • The deny rules block private files, dotfiles, and PHP files inside the uploads folder.

Enable the site, drop the default one, test the syntax, and reload.

sudo ln -s /etc/nginx/sites-available/drupal /etc/nginx/sites-enabled/

sudo rm /etc/nginx/sites-enabled/default

sudo nginx -t

sudo systemctl reload nginx

Checkpoint: Visit your domain. Any Drupal page, such as the installer’s language screen, proves Nginx and PHP-FPM work together. A 502 error or a file download means something is off. The troubleshooting section below covers both.

Nginx or Apache for Drupal?

Both run Drupal well. Nginx uses less memory, which helps on a small VPS, so this guide uses it. Apache reads .htaccess files, and Drupal ships with one. Pick Apache if your team already knows it. The rest of the steps, from the database to SSL, stay almost identical.

Step 6: Set Drupal File and Folder Permissions

Your user owns the code. PHP-FPM runs as www-data, and it only needs write access in two places during setup.

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

cd /var/www/drupal/web/sites/default

cp default.settings.php settings.php

mkdir -p files

sudo chgrp www-data settings.php files

chmod 664 settings.php

chmod 2775 files

Here is the result:

  • Drupal code remains read-only in PHP, which limits the damage from a hacked script.
  • The files folder is writable, so uploads and aggregated CSS and JavaScript work.
  • The settings.php file is writable only until the installer finishes.

This step is mandatory on current releases. Recent Drupal 11 versions stop with an error if settings.php is not writable. Older versions tried to fix the permissions themselves.

Checkpoint: Run ls -l in the default folder. Both settings.php and files should show the www-data group.

Step 7: Run the Drupal Installer

Open the link to the site in your browser. SSL comes next, so plain HTTP is fine for now. Drupal redirects you to the installer.

Work through the screens in this order:

  1. Language. Pick English, or your site’s main language.
  2. Installation profile. Choose Standard for a normal site. Minimal gives you a bare start.
  3. Requirements check. Every line should be green. Fix any red item before you continue.
  4. Database. Select “MySQL, MariaDB, or equivalent”. Enter drupal as the database name, plus the user and password from Step 3. Leave the host as localhost.
  5. Install. Drupal builds its tables. Wait one or two minutes.
  6. Configure the site. Enter a site name, an email address, and an admin username. Choose a long admin password, then set your country and time zone.

Checkpoint: Log in at /user/login with your new admin account. You should land on a Drupal dashboard with the admin toolbar across the top.

Step 8: Add Free SSL with Certbot

Right now your site runs on plain HTTP. Fix that with Certbot.

sudo apt install -y certbot python3-certbot-nginx

sudo certbot --nginx -d example.com -d www.example.com

Certbot asks for an email address and asks you to accept the terms. Then it fetches the certificate, edits your Nginx file, and sets up the HTTP-to-HTTPS redirect. Both domain names must already resolve to this server, or the check fails.

Certbot also installs a timer that automatically renews certificates. Test it with a dry run.

sudo certbot renew --dry-run

Checkpoint: Load https://example.com. The browser should show a lock icon, and http:// should redirect to https://. The dry run should end with a success message.

Step 9: Verify and Lock Down Your New Drupal Site

Start with Drupal’s own health report. Go to Reports > Status report, or open /admin/reports/status. Fix every red error. Read each yellow warning, too, since many are quick wins.

Next, protect settings.php. Open it and add your trusted hosts near the bottom.

$settings['trusted_host_patterns'] = [

  '^example\.com$',

  '^www\.example\.com$',

];

This setting blocks host header attacks. After saving, make the file read-only.

chmod 444 /var/www/drupal/web/sites/default/settings.php

Then set up cron. The Standard profile runs Automated Cron, which fires on visitor traffic. A system cron job is more reliable on a quiet site. Open Configuration > System > Cron, copy the cron URL, and add it to your crontab.

crontab -e

*/15 * * * * curl -s "https://example.com/cron/YOUR_CRON_KEY" > /dev/null

Finally, take a first backup before you touch any module.

mariadb-dump -u drupal -p drupal > ~/drupal-backup.sql

tar -czf ~/drupal-files.tar.gz -C /var/www/drupal/web/sites/default files

Checkpoint: The status report should show no errors. Also confirm that both backup files exist in your home folder.

Fixing Common Drupal Install Errors on a VPS

CSS and JS files return 404, or the site has no styling

This error hits many fresh Nginx installs. Start with the log.

sudo tail -n 50 /var/log/nginx/error.log

Then check three things. First, confirm root ends in /web. Next, confirm the try_files rules from Step 5 are in place. Finally, check that sites/default/files is writable by www-data, since Drupal writes its aggregated CSS and JS there. Reload Nginx and clear the Drupal cache after each fix.

502 Bad Gateway

Nginx cannot reach PHP-FPM. First, run systemctl status php8.3-fpm. Then run ls /run/php/. The socket name in that folder must match the fastcgi_pass line in your config. A typo in the PHP version is the usual culprit.

Cannot connect to the database

Test the same login by hand with mariadb -u drupal -p drupal. If that fails, recreate the user from Step 3. Also check the host field. It must read localhost on a standard single-server setup.

The installer says settings.php is not writable.

Rerun the commands from Step 6. Confirm that settings.php is owned by the www-data group and has mode 664. Reload the installer page afterward. Once the install finishes, lock the file again with chmod 444.

FAQs

Can I install Drupal from the command line with Drush?

How do I update Drupal after installing it on a VPS?

Your Drupal Site Is Live, Here Is What to Do Next

You now have a working Drupal 11 site on its own VPS. It runs on Nginx, PHP-FPM, and MariaDB, and it serves traffic over HTTPS. Two habits keep it healthy: regular backups and prompt security updates.

Your next stop is Composer-based updates. After that, add the modules your site needs first, such as a page builder, SEO tools, and a caching layer. Install each one with composer require, then enable it from the admin area.

Do you still need a server to follow this guide? Pick a Truehost VPS plan with at least 2 GB of RAM and 2 vCPUs. Choose Ubuntu 24.04 LTS at checkout, then start at Step 1. See Truehost VPS plans 

Truehost website builder home cta

Elias N
Author

Elias N

SEO Expert Nairobi, KEN

SEO nerd by trade. Obsessing over keywords, content, and why Google does what it does.

View All Posts