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
- Alma 9 runs PHP through php-fpm by default.
systemctl enable --now php-fpmseparately; it is not started by httpd. php_value/php_flaglines in.htaccesscause 500 errors under php-fpm. Put limits (upload_max_filesize,post_max_size,memory_limit) in/etc/php.ini(or a pool config) and restart php-fpm.
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
- Two layers: the Linode Cloud Firewall (allow 22, 80, 443, ICMP; drop everything else) and
firewalldon the host (services ssh, http, https;cockpitanddhcpv6-clientremoved). A service on a new port needs a rule in both. Opening it only infirewalldgives a service that tests fine from the server itself and is unreachable from outside, with no log entry on the host because the packets never arrive; a TURN server was dead for two weeks this way (see 1:1 WebRTC voice calls over polled signaling and TURN). The cloud firewall here passes no inbound UDP at all. - fail2ban with an sshd jail (5 retries, 1 hour ban). Configure in
/etc/fail2ban/jail.local, neverjail.conf. Right after a restart the socket may not exist yet, sofail2ban-client statuscan fail for a second; retry before debugging. - Useful extras:
htop,bind-utils(fordig),tmux. - Create a non-root login user in
wheel, and a non-root MySQL user with grants on just the databases it needs for interactive work. Credentials for this server live in the global CLAUDE.md, not here.
Apache basics that bite
.htaccessis ignored unless the<Directory>block hasAllowOverride All.- Front-controller frameworks (Slim, Laravel) need the DocumentRoot on
public/, not the app root. See Slim 4 PHP APIs (and migrating from Limonade). - More vhost traps (global
/icons/alias, manifests, SPA fallback) in Apache vhost gotchas (icons alias, manifests, SPA fallback, redirects).
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
- The 1 GB Nanode has a 25 GB disk; check
df -hbefore copying anything large. At one point it was 96% full and a 752 MB video directory was symlinked instead of copied. - If you need root from an automated session, upload a script and run it with sudo, rather than
piping the script into
sudo -S(sudo consumes stdin).
See also
- nginx in front of Apache (TLS proxy on :8008)
- SELinux file contexts and booleans on web servers
- Apache vhost gotchas (icons alias, manifests, SPA fallback, redirects)
- PHP 7 to 8 upgrade breakage and other PHP traps
- Sending mail from PHP with Postfix, SPF, DKIM and DMARC
Linked from
- 1:1 WebRTC voice calls over polled signaling and TURN
- Apache vhost gotchas (icons alias, manifests, SPA fallback, redirects)
- Memory thrash and capacity on a 1 GB VPS
- Moving a website to a new server without downtime
- nginx in front of Apache (TLS proxy on :8008)
- Nightly MySQL/MariaDB backups with mysqldump and cron
- PHP 7 to 8 upgrade breakage and other PHP traps
- Responding to a critical PHP security release (and what to do with an unpatchable server)
- SELinux file contexts and booleans on web servers
- Sending mail from PHP with Postfix, SPF, DKIM and DMARC