📚 Encyclopedia

Servers & Hosting · updated 2026-11-16

Setting up an Alma Linux 9 LAMP server

alma-linuxrhel9phpmariadbcertbotphp-fpmfail2banfirewalld

How the Linode Alma Linux 9 server (45.79.9.71) was built for PHP + MySQL web apps, and the traps hit along the way. Alma 9 is a RHEL 9 rebuild, so everything here applies to Rocky and RHEL 9 too. The default package versions are old, PHP runs under php-fpm rather than mod_php, and SELinux is enforcing, so a plain "dnf install" LAMP recipe from an Ubuntu guide fails in several quiet ways.

Install order and versions

PHP 8.3 via module streams. The distro default is PHP 8.0 (end of life). Switch the stream before installing anything PHP:

dnf module reset php -y && dnf module enable php:8.3 -y
dnf install php php-fpm php-mysqlnd php-gd php-mbstring php-xml ...

EPEL's php-sodium is built for 8.0 and conflicts with the 8.3 stream; skip sodium or exclude the EPEL package. Remi is available, but the AppStream module stream is enough for 8.3.

MariaDB 10.11 from the official repo. Alma 9 ships MariaDB 10.5. For the 10.11 LTS add a repo file:

[mariadb]
baseurl = https://mirror.mariadb.org/yum/10.11/rhel9-amd64

Remove the distro MariaDB first, then install MariaDB-server MariaDB-client (capital M; the upstream package names differ from the distro's). Note that the result is MariaDB, not MySQL, even though everything calls it "mysql".

certbot needs EPEL: dnf install epel-release, then certbot plus the plugin you use (python3-certbot-nginx once nginx fronts Apache, see nginx in front of Apache (TLS proxy on :8008)).

Versions installed in March 2026: Apache 2.4.62, PHP 8.3.29, MariaDB 10.11.16, Composer 2.9.5, Postfix 3.5.25.

php-fpm, not mod_php

SELinux booleans a PHP app needs

SELinux is enforcing. Out of the box Apache/PHP cannot do any of these:

setsebool -P httpd_can_network_connect_db 1   # PDO to MySQL/MariaDB
setsebool -P httpd_can_sendmail 1             # PHP mail()
setsebool -P httpd_can_network_connect 1      # any outbound HTTP (FCM, APIs, Anthropic)

Writable directories (uploads, SQLite, sessions) need the httpd_sys_rw_content_t type. See SELinux file contexts and booleans on web servers for labeling and the /tmp copy trap.

Firewall and hardening

Apache basics that bite

SSH post-quantum warning

A modern client (OpenSSH 10.x) warns that the server does not offer post-quantum key exchange. Alma 9 is pinned at OpenSSH 8.7 and will never get 9.0+, which is required for sntrup761x25519-sha512@openssh.com. Silence only that warning, per host, in the client's ~/.ssh/config:

Host 45.79.9.71
    WarnWeakCrypto no-pq-kex

This is not a practical risk unless you worry about "store now, decrypt later" quantum attacks.

Coming from the old CentOS 7 server

The previous Linode (CentOS 7, being decommissioned) ran PHP 7.3, MariaDB 5.5 and Apache 2.4.6. Differences that mattered during the move: - CentOS 7 has only Python 2.7, so server-side patching there was done with throwaway PHP scripts run by /usr/bin/php (not on PATH as php). - Apache 2.4.6 needed a separate SSLCertificateChainFile; on the new server TLS lives in nginx. - Workarounds written for MariaDB 5.5 may be unnecessary on 10.11, while 10.11's strict mode rejects NULLs that 5.5 tolerated. Test before carrying either direction forward. - PHP 8 breakage in old code: see PHP 7 to 8 upgrade breakage and other PHP traps.

Gotchas

See also

Linked from

Sources: infra memory (server-setup-gotchas, MEMORY.md), 2026-03, tldr memory (feature-voice-calls)