How to Install Drupal with LEMP on CentOS Stream 10

Install Drupal with LEMP on CentOS Stream 10 using Nginx, MariaDB, PHP-FPM, firewalld, SELinux, HTTPS, and secure clean URLs, checks, and fixes.
A 3D web server, database cylinder, and content panels linked by cyan light trails on a dark navy background.

Install Drupal with LEMP on CentOS Stream 10 and finish with a Drupal 11 site served by Nginx, PHP-FPM, and MariaDB in about 25 minutes. You will build the stack over SSH, secure the writable directories, add HTTPS, and finish the setup in Drupal’s browser installer.

Prerequisites

  • A fresh CentOS Stream 10 VPS with at least 2 GB of RAM and 10 GB of free disk space. Media, modules, logs, and backups will need additional room.
  • SSH access as root, or a normal account with working sudo privileges.
  • A public IPv4 address and a domain such as YOUR_DOMAIN whose A record points to SERVER_IP. The domain is needed for a trusted Let’s Encrypt certificate.
  • A long, unique database password and a separate Drupal administrator password. Replace every uppercase placeholder before executing a command or submitting a form.
  • If you need the server first, choose a VPSLake Linux VPS with root access and CentOS Stream 10 support.

This guide installs Drupal 11.4.8 from the official release archive. Drupal 11 needs PHP 8.3 or newer, MariaDB 10.6 or newer, PDO, and extensions such as XML, GD, cURL, Mbstring, and zlib; see Drupal’s system requirements and the 11.4.8 release page for the supported platform details.

Step 1: Install Nginx, MariaDB, PHP-FPM, and firewalld

Install the complete stack from the CentOS Stream repositories so the services, package names, and PHP extensions agree with the operating system.

sudo dnf update -y
sudo dnf install -y nginx firewalld mariadb-server php php-cli php-fpm php-mysqlnd php-gd php-mbstring php-xml php-opcache php-curl php-zip php-intl curl tar gzip policycoreutils-python-utils
sudo systemctl enable --now firewalld nginx mariadb php-fpm
php -v
nginx -v

The PHP version must start with 8.3, and both version commands should complete without an error. Nginx serves static files and passes PHP requests to PHP-FPM instead of embedding PHP in the web server.

PHP 8.3.x (cli) (built: ...)
nginx version: nginx/...

Step 2: Open SSH and web traffic

Allow administration and the two web protocols, but do not open MariaDB’s port because Drupal will use a local database connection.

sudo firewall-cmd --permanent --zone=public --add-service=ssh
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
sudo firewall-cmd --zone=public --list-services

The last command should list ssh, http, and https. If your SSH daemon uses a custom port, add that port before reloading firewalld so the new rules do not cut off your session.

Step 3: Create a private MariaDB database

Drupal should have its own database and local-only account; using the MariaDB administrator in the web application would make a Drupal compromise much more serious.

Run the hardening assistant and remove anonymous users, the test database, and remote administrative access when prompted:

sudo mariadb-secure-installation

Now create the database with UTF-8 support. Replace YOUR_DB_PASSWORD with a strong password that contains no single quote, then save it for the browser installer.

sudo mariadb -e "CREATE DATABASE drupal CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'YOUR_DB_PASSWORD'; GRANT ALL PRIVILEGES ON drupal.* TO 'drupaluser'@'localhost'; FLUSH PRIVILEGES;"
sudo mariadb -e "SELECT VERSION() AS mariadb_version; SHOW DATABASES LIKE 'drupal';"

The result should show a MariaDB version and one database named drupal:

mariadb_version
10.11.x-MariaDB
Database (drupal)
drupal

Step 4: Download Drupal and set safe file labels

The release archive contains Drupal’s runtime dependencies, so Composer is not needed for this first deployment. Pinning the current 11.4.8 security release also prevents an unattended major-version change during installation.

cd /var/www
sudo curl -fL https://ftp.drupal.org/files/projects/drupal-11.4.8.tar.gz -o /tmp/drupal-11.4.8.tar.gz
sudo tar -tzf /tmp/drupal-11.4.8.tar.gz | head -n 1
sudo tar -xzf /tmp/drupal-11.4.8.tar.gz -C /var/www
sudo mv /var/www/drupal-11.4.8 /var/www/drupal
sudo rm -f /tmp/drupal-11.4.8.tar.gz

The archive check should begin with drupal-11.4.8/. Keep the application code owned by root, let the Nginx group read it, and grant Nginx write access only where Drupal needs it during installation.

sudo chown -R root:nginx /var/www/drupal
sudo find /var/www/drupal -type d -exec chmod 750 {} +
sudo find /var/www/drupal -type f -exec chmod 640 {} +
sudo install -d -o nginx -g nginx -m 0770 /var/www/drupal/sites/default/files
sudo cp /var/www/drupal/sites/default/default.settings.php /var/www/drupal/sites/default/settings.php
sudo chown root:nginx /var/www/drupal/sites/default/settings.php
sudo chmod 660 /var/www/drupal/sites/default/settings.php
sudo semanage fcontext -a -t httpd_sys_content_t '/var/www/drupal(/.*)?'
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/drupal/sites/default/files(/.*)?'
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/drupal/sites/default/settings.php'
sudo restorecon -RFv /var/www/drupal
sudo setsebool -P httpd_can_network_connect_db 1

The persistent SELinux rules allow content to be read while limiting web-process writes to Drupal’s files directory and installer settings file. The database boolean permits PHP-FPM to reach MariaDB without disabling SELinux.

Step 5: Create a dedicated PHP-FPM pool

A separate pool gives this site its own Unix socket and worker limits, making the Nginx-to-PHP handoff explicit instead of relying on the default Apache-oriented pool.

sudo tee /etc/php-fpm.d/drupal.conf >/dev/null <<'FPM'
[drupal]
user = nginx
group = nginx
listen = /run/php-fpm/drupal.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
pm = dynamic
pm.max_children = 20
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 500
FPM

sudo tee /etc/php.d/90-drupal.ini >/dev/null <<'INI'
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 120
INI

sudo php-fpm -t
sudo systemctl restart php-fpm
sudo systemctl is-active php-fpm

The configuration test should report success and the final command should print active. The 256 MB memory limit gives Drupal room for its installer and common modules without changing the system’s global resource policy.

Step 6: Configure the Nginx server block

Nginx needs a front-controller rule for Drupal’s clean URLs, a FastCGI socket, and explicit blocks for executable files that should never be served from the public files directory.

Remove the package’s placeholder site if it exists, then create the server block. Replace YOUR_DOMAIN and ADMIN_EMAIL with real values.

sudo rm -f /etc/nginx/conf.d/default.conf
sudo tee /etc/nginx/conf.d/drupal.conf >/dev/null <<'NGINX'
server {
    listen 80;
    server_name YOUR_DOMAIN;
    root /var/www/drupal;
    index index.php index.html;
    client_max_body_size 64m;

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

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

    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_pass unix:/run/php-fpm/drupal.sock;
    }

    location ~* \.(?:engine|inc|install|make|module|profile|po|sh|sql|theme|twig|tpl|yml)(?:~|\.sw[op]|\.bak|\.orig|\.save)?$ {
        deny all;
    }
}
NGINX

sudo nginx -t
sudo systemctl reload nginx

Nginx should return syntax is ok and test is successful. The try_files rule sends missing paths to Drupal’s front controller while still serving images, CSS, and JavaScript directly.

Step 7: Add HTTPS and run the Drupal installer

Let’s Encrypt needs the domain to resolve to this VPS and port 80 to be reachable from the internet. Install Certbot from EPEL, let it update the Nginx block, and force HTTP requests onto HTTPS.

sudo dnf install -y epel-release
sudo dnf install -y certbot python3-certbot-nginx
sudo certbot --nginx --redirect --domain YOUR_DOMAIN --email ADMIN_EMAIL --agree-tos --no-eff-email
sudo certbot renew --dry-run

The renewal test should end with a success message. Open https://YOUR_DOMAIN/core/install.php, select English, choose the Standard profile, and select MySQL, MariaDB, or equivalent.

Use these database values:

  • Database name: drupal
  • Database username: drupaluser
  • Database password: YOUR_DB_PASSWORD
  • Database host: localhost
  • Database port: 3306

Create a unique administrator username, a long password, and a monitored email address. Drupal will create its tables and redirect you to the site’s front page when the wizard completes.

Verify the Drupal LEMP installation

Check the service state, Nginx syntax, HTTPS response, and database from SSH, then open the site in a private browser window. These checks catch a broken daemon or virtual host before you start adding content.

sudo systemctl is-active nginx php-fpm mariadb firewalld
sudo nginx -t
curl -fsSI https://YOUR_DOMAIN/
sudo mariadb -e "SHOW DATABASES LIKE 'drupal';"

Expected results are four active lines, a successful Nginx test, an HTTP 200 or Drupal redirect, and a row named drupal:

active
active
active
active
nginx: configuration file /etc/nginx/nginx.conf test is successful
HTTP/2 200
drupal

In Drupal, open Manage → Reports → Status report and fix any warning about trusted hosts, PHP extensions, or file permissions.

Troubleshooting

502 Bad Gateway

Nginx cannot reach the PHP-FPM socket, usually because the pool failed to start or the socket path in the two configuration files differs. Confirm the socket and inspect the service log.

sudo ls -l /run/php-fpm/drupal.sock
sudo grep -E '^(listen|user|group)' /etc/php-fpm.d/drupal.conf
sudo journalctl -u php-fpm -n 40 --no-pager
sudo systemctl restart php-fpm nginx

403 Forbidden or the installer says files are not writable

The Unix owner, group mode, or SELinux context is wrong. Restore the labels and recreate only Drupal’s intended writable directory; do not solve this by making the whole site world-writable.

sudo chown -R root:nginx /var/www/drupal
sudo install -d -o nginx -g nginx -m 0770 /var/www/drupal/sites/default/files
sudo restorecon -RFv /var/www/drupal
sudo systemctl restart php-fpm nginx

Access denied for user 'drupaluser'@'localhost'

The password in the installer does not match the local MariaDB account, or the account was created with a different host value. Reset it through the local administrative socket and enter the same value again.

sudo mariadb -e "ALTER USER 'drupaluser'@'localhost' IDENTIFIED BY 'YOUR_DB_PASSWORD'; FLUSH PRIVILEGES;"

Certbot reports a failed challenge

The DNS record may still point to another address, or port 80 may be blocked by firewalld or an upstream VPS firewall. Check both the public DNS result and the local service before retrying.

sudo firewall-cmd --zone=public --list-services
curl -I http://YOUR_DOMAIN/
sudo certbot --nginx --redirect --domain YOUR_DOMAIN

Hardening

  • After the web installer finishes, make settings.php read-only and restore its normal SELinux label:
  sudo chmod 640 /var/www/drupal/sites/default/settings.php
  sudo chown root:nginx /var/www/drupal/sites/default/settings.php
  sudo restorecon -v /var/www/drupal/sites/default/settings.php
  • Add YOUR_DOMAIN and any deliberate www alias to Drupal’s trusted-host settings in sites/default/settings.php so unexpected Host headers are rejected.
  • Keep MariaDB local-only, back up the database and /var/www/drupal, and apply CentOS and Drupal security updates before installing new modules.
  • For a repeatable SSH baseline, use VPSLake’s SSH hardening generator.

FAQ

Does CentOS Stream 10 support Drupal 11?

Yes. Drupal 11 requires PHP 8.3 or newer and MariaDB 10.6 or newer, and the packages installed here provide those requirements. The PHP extension list can grow when you add contributed modules, so review a module’s requirements before enabling it.

Why use a separate PHP-FPM pool for Nginx?

The pool gives Drupal a predictable socket, worker limits, and nginx ownership. It also avoids accidentally pointing the server block at a pool intended for a different web server or application.

Can I install Drupal using only the VPS IP address?

You can use the IP for a temporary HTTP test, but a domain is the practical production choice. Certbot needs a domain that resolves publicly, and Drupal’s trusted-host protection is easier to configure with a stable hostname.

Do I need Composer for this tutorial?

No. The official release archive is enough for a single-site installation. Composer is the better long-term workflow when you manage Drupal core, modules, and themes in a project repository, so use it for repeatable deployments and controlled updates.

Samrat Ghosh
Written by

Samrat Ghosh

Founder & Infrastructure Engineer

Samrat Ghosh is the founder of VPSLake, where he builds and runs the remote desktop and VPS hosting infrastructure the company is built on. He writes hands-on guides about RDP, Windows Server, VPS management and secure remote access - the practical documentation he wishes had…

Previous Article

Best VPS Under $5 a Month in 2026

Next Article

How to Install Drupal with LEMP on CentOS Stream 9

Write a Comment

Leave a Comment

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

Subscribe to our Newsletter

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨