Install Drupal with LAMP on CentOS Stream 9 and finish with a working Drupal 11 site behind Apache, MariaDB, PHP-FPM, and HTTPS in about 20–30 minutes. You will prepare the stack over SSH, then complete Drupal’s setup in a browser.
Prerequisites
- A fresh CentOS Stream 9 VPS with at least 2 GB RAM and 10 GB of free disk space. Composer is not required for this archive-based install, but Drupal and its modules still need room to grow.
- SSH access as
root, or a normal account with workingsudoprivileges. - A public IPv4 address and a domain such as
YOUR_DOMAINpointing toSERVER_IP. The domain is needed for a trusted HTTPS certificate. - A unique database password and a separate strong Drupal administrator password. Replace every uppercase placeholder before running a command or filling in the installer.
- If you need the server first, choose a VPSLake Linux VPS with root access and CentOS Stream 9 support.
This guide installs Drupal 11.4.7, a production release in the Drupal 11 branch. Drupal 11 needs PHP 8.3 or newer, MariaDB 10.6 or newer, PDO, XML, GD, cURL, OpenSSL, Mbstring, and ZIP; see Drupal’s system requirements for the requirements behind these choices.
Step 1: Install Apache, MariaDB, PHP-FPM, and required extensions
Enable PHP 8.3 before installing the packages so CentOS Stream 9 does not select its older default PHP stream.
sudo dnf update -y
sudo dnf module reset php -y
sudo dnf module enable php:8.3 -y
sudo dnf install -y httpd firewalld mariadb-server curl tar policycoreutils-python-utils php php-cli php-fpm php-mysqlnd php-gd php-mbstring php-xml php-opcache php-curl php-zip php-intl
sudo systemctl enable --now firewalld httpd mariadb php-fpm
php -v
The version line should start with PHP 8.3. The php-fpm service handles PHP requests through FastCGI, while Apache serves Drupal’s static files.
PHP 8.3.x (cli) (built: ...)
Step 2: Allow SSH and web traffic through firewalld
Open only the ports needed for administration and the website; MariaDB stays private on the server.
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 output should include ssh, http, and https. If your SSH daemon listens on a custom port, add that port before reloading the firewall so you do not lose access.
Step 3: Create a private MariaDB database for Drupal
Drupal should use its own database account rather than MariaDB’s administrative account.
First run the hardening assistant and accept the secure options: remove anonymous users, block remote root login, remove the test database, and reload privilege tables.
sudo mariadb-secure-installation
Create the database with UTF-8 support and restrict the application account to local connections. Replace YOUR_DB_PASSWORD with a long password that is not used anywhere else.
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';"
You should see a MariaDB version and one database row named drupal.
mariadb_version
11.x.x-MariaDB
Database (drupal)
drupal
Step 4: Download Drupal and set SELinux-aware permissions
Use the official Drupal 11.4.7 archive so the commands install a known production release instead of silently changing the major version later.
cd /var/www
sudo curl -fL https://ftp.drupal.org/files/projects/drupal-11.4.7.tar.gz -o /tmp/drupal-11.4.7.tar.gz
sudo tar -tzf /tmp/drupal-11.4.7.tar.gz | head
sudo tar -xzf /tmp/drupal-11.4.7.tar.gz -C /var/www
sudo mv /var/www/drupal-11.4.7 /var/www/drupal
sudo rm -f /tmp/drupal-11.4.7.tar.gz
The archive listing should begin with drupal-11.4.7/. Keep the application readable by Apache, but make only Drupal’s public files directory writable by the web process.
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
chcon temporarily lets the installer update settings.php; the final hardening step removes that write access. The persistent semanage rule lets Drupal create uploads and generated assets without disabling SELinux.
Step 5: Configure PHP and the Apache virtual host
Drupal’s .htaccess file provides clean URLs, so Apache must allow overrides for this virtual host.
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
Replace YOUR_DOMAIN and ADMIN_EMAIL in the virtual host before saving it.
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 php-fpm httpd
apachectl configtest must return Syntax OK, followed by active for both services.
Syntax OK
active
active
Step 6: Add HTTPS before entering administrator credentials
Point the domain’s A record to SERVER_IP first. Certbot can then validate the site over HTTP and add an Apache HTTPS configuration.
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 prompted. If you are testing with an IP address only, postpone this step, but use a real domain and TLS before collecting passwords or publishing the site.
Step 7: Run the Drupal web installer
The browser installer creates Drupal’s tables and the first administrator account after the server-side prerequisites are ready.
Open https://YOUR_DOMAIN/core/install.php and choose English, the Standard profile, and MySQL, MariaDB, or equivalent.
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 unique administrator username, a long password, and an email address you monitor. Drupal should redirect you to the new site’s front page when the installation finishes.
Verify the Drupal LAMP installation
Run these checks from SSH, then load the site over HTTPS in a separate browser. Together they verify the services, Apache syntax, the public response, the database, and Drupal’s required PHP modules.
sudo systemctl is-active httpd php-fpm mariadb firewalld
sudo apachectl configtest
curl -fsSI https://YOUR_DOMAIN/
php -m | grep -E 'curl|dom|gd|mbstring|PDO|pdo_mysql|xml|zip'
sudo mariadb -e "SHOW DATABASES LIKE 'drupal';"
active
active
active
active
Syntax OK
HTTP/2 200
curl
gd
mbstring
PDO
pdo_mysql
xml
zip
drupal
Expected results are four active lines, Syntax OK, an HTTP 200 or Drupal redirect, module names in the PHP check, and one drupal database row. In Drupal, open Manage → Reports → Status report and resolve warnings about trusted hosts, permissions, or PHP extensions.
Troubleshooting
dnf cannot enable php:8.3
The PHP module metadata may be stale, or an older PHP stream may already be installed. Refresh packages and check the available streams; do not mix unrelated PHP package families on the same server.
sudo dnf clean metadata
sudo dnf makecache
sudo dnf module list php
If 8.3 is listed, reset the stream and enable it again, then reinstall the PHP packages from Step 1. Drupal 11.4 cannot run on PHP 8.0 or 8.1.
403 Forbidden or 500 Internal Server Error
The common causes are a missing AllowOverride All, incorrect file labels, or a PHP-FPM failure. Read the Apache log, restore the SELinux labels, and validate the virtual host.
sudo tail -n 40 /var/log/httpd/drupal_error.log
sudo restorecon -Rv /var/www/drupal
sudo apachectl configtest
sudo systemctl restart php-fpm httpd
Access denied for user 'drupaluser'@'localhost'
The installer password does not match the MariaDB account, or the account was created with a different host value. Reset the local account and enter the same password 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 DNS record may still point to another server, or port 80 may be blocked by firewalld or the VPS provider’s network firewall. Confirm the public A record and test the HTTP virtual host before running Certbot again.
sudo firewall-cmd --zone=public --list-services
curl -I http://YOUR_DOMAIN/
sudo certbot --apache --domain YOUR_DOMAIN
Hardening
- After the web installer completes, remove write access from the settings file and restore its normal SELinux label:
sudo chmod 640 /var/www/drupal/sites/default/settings.php
sudo chown root:apache /var/www/drupal/sites/default/settings.php
sudo restorecon -v /var/www/drupal/sites/default/settings.php
- Configure Drupal trusted hosts for
YOUR_DOMAINand any deliberatewwwalias insites/default/settings.php. - Keep MariaDB local-only, back up
/var/www/drupaland thedrupaldatabase, and take a backup before core or module updates. - Apply CentOS security updates regularly and use a separate administrator account for routine Drupal work.
FAQ
Why install Drupal 11 instead of the latest download?
This guide pins Drupal 11.4.7 because it is a supported production branch that matches PHP 8.3 and MariaDB 10.6 or newer. Pinning prevents a later major release with different platform requirements from breaking a repeat installation; review Drupal’s official release page before upgrading.
Can I use an IP address instead of a domain?
You can use the IP for a temporary HTTP test, but a domain is the practical choice for production. It makes HTTPS, trusted-host protection, email delivery, and future site migrations much easier to manage.
Do I need Composer for this installation?
No. The official release archive is enough for this single-site setup. Composer is the better choice when you manage Drupal core and contributed modules as a dependency-controlled project, so plan a Composer-based deployment for a development team.
Which directory should Drupal make writable?
Only sites/default/files should remain writable by Apache after installation because it stores uploads and generated assets. The application code and settings.php should be readable but not writable by the web process.