How to Install Drupal with LAMP on CentOS Stream 10

Install Drupal with LAMP on CentOS Stream 10 using Apache, MariaDB, PHP-FPM, firewalld, SELinux-safe permissions, HTTPS, checks, and clear fixes.
A polished 3D server, CMS panel, and database cylinder connected by blue light trails in a dark server room.

Install Drupal with LAMP on CentOS Stream 10 and finish with a working Drupal 11 site behind Apache, MariaDB, PHP-FPM, and HTTPS in about 20–30 minutes. You will prepare the server over SSH, then complete Drupal’s guided setup in a browser.

Prerequisites

  • A fresh CentOS Stream 10 VPS with at least 2 GB RAM and 10 GB of free disk space. Drupal’s installer and future updates need more memory than a bare PHP page.
  • SSH access as root, or a normal user with working sudo privileges.
  • A domain such as YOUR_DOMAIN with an A record pointing to SERVER_IP; the domain is needed for a trusted HTTPS certificate.
  • A strong database password and a separate strong Drupal administrator password. Replace each uppercase placeholder before running a command or filling in the installer.
  • If you need the server, choose a VPSLake Linux VPS with root access and CentOS Stream 10.

Drupal 11 requires PHP 8.3 or later, MariaDB 10.6 or later, the PDO database extension, and several common PHP extensions. Check the current Drupal system requirements if you plan to add modules with extra dependencies.

Step 1: Update CentOS and install LAMP packages

Install the web server, database, PHP-FPM, Drupal’s required extensions, and SELinux utilities together so the stack uses the CentOS Stream 10 repositories consistently.

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

The PHP version must begin with 8.3 or a newer supported PHP 8 release. CentOS Stream 10 runs PHP through PHP-FPM, which keeps request processing in a managed service instead of depending on the older Apache PHP module.

PHP 8.3.x (cli) (built: ...)

Step 2: Open only the web ports

Allow SSH and the two web protocols while leaving MariaDB private to the VPS; Drupal and PHP can reach the local database without exposing port 3306 to the internet.

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 final command should include ssh, http, and https. If SSH uses a custom port, add that port before reloading firewalld; do not lock yourself out by assuming the default service definition matches your VPS.

Step 3: Create Drupal’s MariaDB database

Drupal needs a dedicated database account so the site does not use MariaDB’s administrative account.

sudo mariadb-secure-installation

Remove anonymous accounts and the test database, disallow remote administrative login, and reload the privilege tables when the hardening script asks. On a fresh MariaDB installation, local root access commonly uses the Unix socket, so sudo mariadb is expected to work without a root password.

Create a UTF-8 database and a local-only application user. Replace YOUR_DB_PASSWORD with a long, unique password and save it for the web 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';"

Expected output includes a MariaDB version and the drupal database:

mariadb_version
10.6.x-MariaDB
Database (drupal)
drupal

Step 4: Download Drupal and apply SELinux-safe permissions

The official release archive is sufficient for a single-site deployment and avoids putting Composer’s vendor directory under a web-accessible parent.

cd /var/www
sudo curl -fL https://www.drupal.org/download-latest/tar.gz -o /tmp/drupal.tar.gz
sudo tar -xzf /tmp/drupal.tar.gz -C /var/www
sudo mv /var/www/drupal-* /var/www/drupal
sudo rm -f /tmp/drupal.tar.gz

Make the application readable by Apache, but give the web process write access only to Drupal’s public files directory and the settings file during installation. This keeps uploads separate from the PHP code.

sudo chown -R root:apache /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 apache -g apache -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:apache /var/www/drupal/sites/default/settings.php
sudo chmod 660 /var/www/drupal/sites/default/settings.php
sudo chcon -t httpd_sys_rw_content_t /var/www/drupal/sites/default/settings.php
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/drupal/sites/default/files(/.*)?'
sudo restorecon -Rv /var/www/drupal/sites/default/files

The chcon line temporarily permits the installer to write settings.php; the final step below restores its read-only SELinux label after installation. The persistent semanage rule lets Drupal create uploads and generated assets without disabling SELinux.

Step 5: Configure Apache and PHP-FPM

Apache must permit Drupal’s .htaccess file, because that file provides clean URLs and several request protections.

Set a practical PHP memory limit and upload size for a new site:

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

Create a virtual host. Replace YOUR_DOMAIN and ADMIN_EMAIL with the real hostname and an address for server notices.

sudo tee /etc/httpd/conf.d/drupal.conf >/dev/null <<'APACHE'
<VirtualHost *:80>
    ServerName YOUR_DOMAIN
    ServerAdmin ADMIN_EMAIL
    DocumentRoot /var/www/drupal

    <Directory /var/www/drupal>
        AllowOverride All
        Options -Indexes +FollowSymLinks -MultiViews
        Require all granted
    </Directory>

    DirectoryIndex index.php index.html
    ErrorLog /var/log/httpd/drupal_error.log
    CustomLog /var/log/httpd/drupal_access.log combined
</VirtualHost>
APACHE
sudo apachectl configtest
sudo systemctl restart php-fpm httpd
sudo systemctl is-active httpd php-fpm

The configuration check must say Syntax OK, and both services should report active:

Syntax OK
active
active

Step 6: Issue an HTTPS certificate

Run this after DNS resolves YOUR_DOMAIN to the VPS and the HTTP virtual host answers from the public internet. Certbot can then complete the challenge and update Apache for HTTPS.

sudo dnf install -y epel-release
sudo dnf install -y certbot python3-certbot-apache
sudo certbot --apache --domain YOUR_DOMAIN

Choose the redirect-to-HTTPS option when Certbot offers it. The certificate is renewed by the installed timer; check it with sudo systemctl list-timers 'certbot*'. If you are testing with an IP address only, skip this step temporarily and do not use an HTTP-only site for real administrator credentials.

Step 7: Run the Drupal browser installer

The server is ready; the web installer now creates Drupal’s tables and the first administrator account.

Open https://YOUR_DOMAIN/core/install.php in a browser. Select English, choose the Standard installation profile, and select MySQL, MariaDB, or equivalent as the database type.

Enter these database values:

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

On the site configuration page, use a descriptive site name, a unique administrator username, a strong password, and an email address you monitor. Do not use admin as the username. Drupal will redirect you to the new front page when the installation finishes.

Verify the Drupal LAMP installation

Run these checks from SSH and load the site over HTTPS from another device. The service check proves the daemons are running, the Apache check validates the vhost, and the database query confirms that the application database exists.

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

Expected results are four active lines, Syntax OK, an HTTP 200 or Drupal redirect response, and one row named drupal. In Drupal, open Manage → Reports → Status report and resolve any warning about file permissions, trusted hosts, or PHP extensions.

Troubleshooting

The installer says PHP 8.3 is required

Drupal 11 will not run on an older PHP release. Confirm both the command-line and PHP-FPM packages, then update the operating system and restart PHP-FPM; do not mix a random third-party PHP repository into the base installation.

php -v
sudo dnf update -y php\*
sudo systemctl restart php-fpm httpd

403 Forbidden or a 500 Internal Server Error

The usual causes are a missing AllowOverride All, incorrect ownership, or an SELinux label that does not match the new path. Check the Apache error log, validate the vhost, and restore the labels before restarting.

sudo tail -n 40 /var/log/httpd/drupal_error.log
sudo apachectl configtest
sudo restorecon -Rv /var/www/drupal
sudo systemctl restart httpd php-fpm

Access denied for user 'drupaluser'@'localhost'

The password in the installer does not match the account, or the database user was created with a different host value. Reset the password using the local administrative socket, then enter the same value in Drupal’s database form.

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

Certbot reports a failed challenge

The domain’s DNS record may still point elsewhere, or port 80 may be blocked by firewalld or the VPS provider’s network firewall. Confirm the public A record, allow HTTP, and try again after the domain resolves to SERVER_IP.

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

Hardening

  • After the installer finishes, make the settings file read-only and restore its normal SELinux type:
  sudo chmod 640 /var/www/drupal/sites/default/settings.php
  sudo restorecon -v /var/www/drupal/sites/default/settings.php
  sudo chown root:apache /var/www/drupal/sites/default/settings.php
  • Configure Drupal trusted hosts in sites/default/settings.php for YOUR_DOMAIN and any deliberate www alias; this blocks unexpected Host headers.
  • Keep MariaDB bound to localhost and back up both /var/www/drupal and the drupal database before core or module updates.
  • Apply operating-system security updates regularly. For a repeatable SSH baseline, you can use VPSLake’s SSH hardening generator.

FAQ

Can I install Drupal 10 instead of Drupal 11?

Yes, but the current archive may install the latest supported branch. Drupal 10 has lower PHP and MariaDB minimums, while Drupal 11 requires PHP 8.3 and MariaDB 10.6 or newer. Pin a supported release only when your project requires it, and plan upgrades before that branch reaches end of life.

Is Composer required for this installation?

No. The official release archive includes the Drupal code and runtime dependencies needed for this basic site. Composer is recommended for teams that manage modules and updates as a version-controlled project, so use the Composer workflow when you need that deployment model.

Why does Drupal need a writable sites/default/files directory?

Drupal stores uploaded media, generated stylesheets, and cached assets there. Only that data directory should be writable by Apache; the application code should remain owned by root and read-only to the web process.

Can I use the VPS IP instead of a domain?

You can use the IP for an initial HTTP connectivity test, but a domain is strongly preferred for production. A domain is required for a normal trusted certificate and makes Drupal’s trusted-host protection and future email configuration predictable.

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

Ryzen vs EPYC Dedicated Server: Which Wins?

Next Article

How to Fix a Remote Desktop Blurry Screen

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 ✨