Vous installez OpenLiteSpeed pour le récit performance WordPress — LSCache est réellement plus rapide que fpm-sur-nginx pour des pages chaudes, et la console WebAdmin rend le premier vhost facile. Six mois plus tard, le WebAdmin est toujours sur :7080 ouvert à internet (parce que l’installation par défaut fait ça), le module LSCache a été activé mais le site WordPress n’a jamais reçu le plugin LiteSpeed Cache, donc rien n’est réellement mis en cache, le job certbot qui récupère les certificats Let’s Encrypt vit dans un cron écrit à la main qui n’a tourné qu’une fois, et le worker LSPHP est resté sur sa Mem Soft Limit par défaut de 256 Mo alors que le profil mémoire du site demande 384.
Ce qui se passe
Un déploiement OpenLiteSpeed en production a besoin que le WebAdmin soit pare-feutré (lié à une interface privée ou restreint par IP source), que le mot de passe admin par défaut soit tourné à la première installation, que LSCache plus le plugin WordPress correspondant soient réellement câblés pour mettre en cache /wp-content/cache/ sur disque, d’un vrai chemin d’automatisation Let’s Encrypt (le acme.sh fourni ou certbot système avec un deploy-hook qui touche /usr/local/lsws/conf/serial.no), d’un handler PHP dont la mémoire et le délai collent à la charge (les Mem Soft/Hard Limit de LSPHP sont des plafonds durs — pas des indications), de gzip/brotli activés au niveau écouteur, de la propagation du request-id pour le plugin WordPress en amont, et d’un journal d’accès qui est un fichier qu’on peut grep — pas juste journald. La console d’admin est un piège : n’importe qui qui scanne :7080 peut essayer les identifiants par défaut.
Comment vérifier
Après installation, les écouteurs doivent ressembler à ça :
ss -lntp | grep -E ':(80|443|7080)\b'
# 0.0.0.0:80 lshttpd
# 0.0.0.0:443 lshttpd
# 127.0.0.1:7080 lshttpd (WebAdmin, localhost uniquement ; tunnel SSH)
La configuration OpenLiteSpeed doit être analysée sans erreur avant tout rechargement :
/usr/local/lsws/bin/lswsctrl -t
Un curl -I contre le vhost doit afficher l’en-tête LSCache et HSTS :
curl -sI https://example.com/ | grep -iE 'strict-transport|x-litespeed-cache|server'
Et la chaîne de certificat doit être Let’s Encrypt production, pas staging :
openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null \
| openssl x509 -noout -issuer -dates
Si X-LiteSpeed-Cache est absent au deuxième hit (un miss au premier est normal), si le WebAdmin répond sur 0.0.0.0:7080, ou si getenforce retourne Permissive, l’installation n’est pas terminée.
Le correctif
Enregistrez le script ci-dessous sous /root/setup-openlitespeed-alma9.sh, puis exécutez-le. Il déroule l’installation complète sur une VM AlmaLinux 9 fraîche : mise à jour de base + EPEL, installe OpenLiteSpeed et LSPHP 82 depuis le dépôt officiel, durcit SSH en gardant la clé root, configure firewalld pour 22/80/443 plus le WebAdmin uniquement depuis un sous-réseau de confiance (ou localhost), applique l’ajustement sysctl pertinent pour un serveur web haute-concurrence, écrit un squelette vhost orienté WordPress avec LSCache + gzip/brotli + request-id, lie le WebAdmin à 127.0.0.1:7080 et tourne le mot de passe admin vers une valeur fournie, récupère un certificat Let’s Encrypt via le acme.sh fourni, installe un deploy hook qui recharge LSWS, monte LimitNOFILE à 200000 via un override systemd, valide la configuration, et attend que les deux écouteurs publics soient prêts avant de continuer.
#!/usr/bin/env bash
set -euo pipefail
### AlmaLinux 9 OpenLiteSpeed installer
### WordPress-ready vhost skeleton with LSCache
### WebAdmin bound to 127.0.0.1:7080 (use SSH tunnel)
### TLS via Let's Encrypt HTTP-01 (acme.sh)
### No local backups; assumes VM-level backup
### Reboot remains manual
if [[ "$(id -u)" -ne 0 ]]; then
echo "Run as root."
exit 1
fi
: "${PRIMARY_DOMAIN:?Set PRIMARY_DOMAIN=example.com before running}"
: "${ACME_EMAIL:?Set ACME_EMAIL=ops@example.com before running}"
: "${ADMIN_USER:?Set ADMIN_USER=opsadmin before running}"
: "${ADMIN_PASSWORD:?Set ADMIN_PASSWORD=... before running}"
echo
echo "========================================"
echo "OpenLiteSpeed AlmaLinux 9 Setup"
echo "========================================"
echo
echo "==> Updating base OS"
dnf -y update
dnf -y install epel-release
dnf -y update
echo "==> Installing base packages"
dnf -y install \
curl \
wget \
ca-certificates \
gnupg2 \
chrony \
fail2ban \
dnf-automatic \
policycoreutils-python-utils \
lsof \
tcpdump \
bind-utils \
iproute \
net-tools \
jq \
socat \
openssl \
tar
echo "==> Enabling time sync"
systemctl enable --now chronyd
timedatectl set-ntp true
echo "==> SELinux enforcing"
if [[ -f /etc/selinux/config ]]; then
sed -i 's/^SELINUX=.*/SELINUX=enforcing/' /etc/selinux/config
fi
setenforce 1 2>/dev/null || true
echo "==> Applying sysctl tuning for web server"
cat > /etc/sysctl.d/99-ols.conf <<'SYSCTL'
net.core.somaxconn = 32768
net.core.netdev_max_backlog = 250000
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 10240 65535
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
fs.file-max = 2097152
SYSCTL
modprobe tcp_bbr || true
echo tcp_bbr > /etc/modules-load.d/bbr.conf
sysctl --system
echo "==> Setting file limits"
cat > /etc/security/limits.d/99-ols.conf <<'LIMITS'
* soft nofile 200000
* hard nofile 200000
root soft nofile 200000
root hard nofile 200000
nobody soft nofile 200000
nobody hard nofile 200000
LIMITS
echo "==> Hardening SSH"
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak.$(date +%F-%H%M%S)
set_sshd_option() {
local key="$1"
local value="$2"
if grep -qE "^[#[:space:]]*${key}[[:space:]]+" /etc/ssh/sshd_config; then
sed -i "s|^[#[:space:]]*${key}[[:space:]].*|${key} ${value}|" /etc/ssh/sshd_config
else
echo "${key} ${value}" >> /etc/ssh/sshd_config
fi
}
set_sshd_option PermitRootLogin prohibit-password
set_sshd_option PasswordAuthentication no
set_sshd_option PubkeyAuthentication yes
set_sshd_option KbdInteractiveAuthentication no
set_sshd_option ChallengeResponseAuthentication no
set_sshd_option X11Forwarding no
set_sshd_option ClientAliveInterval 300
set_sshd_option ClientAliveCountMax 2
set_sshd_option MaxAuthTries 4
sshd -t
systemctl restart sshd
echo "==> Configuring firewalld (22, 80, 443; WebAdmin localhost only)"
systemctl enable --now firewalld
firewall-cmd --permanent --remove-service=cockpit 2>/dev/null || true
firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
echo "==> Configuring fail2ban for SSH"
mkdir -p /etc/fail2ban/jail.d
cat > /etc/fail2ban/jail.d/sshd.local <<'F2B'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
F2B
systemctl enable --now fail2ban
echo "==> Configuring automatic security updates"
cat > /etc/dnf/automatic.conf <<'DNFAUTO'
[commands]
upgrade_type = security
random_sleep = 900
download_updates = yes
apply_updates = yes
[emitters]
emit_via = stdio
[base]
debuglevel = 1
DNFAUTO
systemctl enable --now dnf-automatic.timer
echo "==> Adding LiteSpeed repository"
rpm -ivh https://rpms.litespeedtech.com/centos/litespeed-repo-1.2-1.el9.noarch.rpm || \
dnf -y install https://rpms.litespeedtech.com/centos/litespeed-repo-1.2-1.el9.noarch.rpm
echo "==> Installing OpenLiteSpeed + LSPHP 8.2 + WP cache module"
dnf -y install openlitespeed lsphp82 lsphp82-common lsphp82-mysqlnd lsphp82-process lsphp82-opcache lsphp82-pdo lsphp82-gd lsphp82-mbstring lsphp82-xml lsphp82-json
# Default lsphp symlink to lsphp82
ln -sf /usr/local/lsws/lsphp82/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp
echo "==> Binding WebAdmin to 127.0.0.1:7080"
sed -i 's|adminListener .*|adminListener|; s|address \*:7080|address 127.0.0.1:7080|' /usr/local/lsws/admin/conf/admin_config.conf 2>/dev/null || true
# If the config form is different in this version, fall through to httpd_config.xml override below
mkdir -p /usr/local/lsws/admin/conf
cat > /usr/local/lsws/admin/conf/admin_listeners.conf <<'ADMIN_LISTENER'
listener adminListener {
address 127.0.0.1:7080
secure 1
keyFile $SERVER_ROOT/admin/conf/webadmin.key
certFile $SERVER_ROOT/admin/conf/webadmin.crt
clientVerify 0
}
ADMIN_LISTENER
echo "==> Rotating WebAdmin credentials"
ENCPASS=$(/usr/local/lsws/admin/fcgi-bin/admin_php -q /usr/local/lsws/admin/misc/htpasswd.php "${ADMIN_PASSWORD}" 2>/dev/null || \
openssl passwd -apr1 "${ADMIN_PASSWORD}")
echo "${ADMIN_USER}:${ENCPASS}" > /usr/local/lsws/admin/conf/htpasswd
chmod 600 /usr/local/lsws/admin/conf/htpasswd
chown lsadm:lsadm /usr/local/lsws/admin/conf/htpasswd
echo "==> Writing WordPress vhost skeleton for ${PRIMARY_DOMAIN}"
VHROOT="/var/www/${PRIMARY_DOMAIN}"
mkdir -p "${VHROOT}"/{html,logs,conf,cache}
chown -R nobody:nobody "${VHROOT}"
mkdir -p "/usr/local/lsws/conf/vhosts/${PRIMARY_DOMAIN}"
cat > "/usr/local/lsws/conf/vhosts/${PRIMARY_DOMAIN}/vhconf.conf" <<VHCONF
docRoot ${VHROOT}/html
enableGzip 1
enableBr 1
cgroups 0
errorlog ${VHROOT}/logs/error.log {
useServer 0
logLevel INFO
rollingSize 100M
}
accesslog ${VHROOT}/logs/access.log {
useServer 0
logFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %D %{X-Request-Id}o"
rollingSize 100M
keepDays 14
compressArchive 1
}
index {
useServer 0
indexFiles index.php, index.html
}
scripthandler {
add lsapi:lsphp82 php
}
extprocessor lsphp82 {
type lsapi
address uds://tmp/lshttpd/lsphp82.sock
maxConns 64
env LSAPI_CHILDREN=64
initTimeout 60
retryTimeout 0
persistConn 1
pcKeepAliveTimeout 60
respBuffer 0
autoStart 1
path /usr/local/lsws/lsphp82/bin/lsphp
memSoftLimit 384M
memHardLimit 512M
procSoftLimit 400
procHardLimit 500
}
context / {
location ${VHROOT}/html
allowBrowse 1
rewrite {
enable 1
autoLoadHtaccess 1
}
}
module cache {
storagePath ${VHROOT}/cache
}
rewrite {
enable 1
autoLoadHtaccess 1
logLevel 0
}
# Security + request id headers
extraHeaders <<HDRS
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
HDRS
VHCONF
echo "==> Wiring vhost into main config"
cat >> /usr/local/lsws/conf/httpd_config.conf <<VHOST_REF
virtualhost ${PRIMARY_DOMAIN} {
vhRoot ${VHROOT}
configFile \$SERVER_ROOT/conf/vhosts/${PRIMARY_DOMAIN}/vhconf.conf
allowSymbolLink 1
enableScript 1
restrained 1
setUIDMode 0
}
VHOST_REF
# Listeners (HTTP + HTTPS)
cat >> /usr/local/lsws/conf/httpd_config.conf <<'LISTENERS_REF'
listener Default {
address *:80
secure 0
map PRIMARY_HOST PRIMARY_DOMAIN
}
listener DefaultSSL {
address *:443
secure 1
keyFile /etc/letsencrypt/live/PRIMARY_DOMAIN/privkey.pem
certFile /etc/letsencrypt/live/PRIMARY_DOMAIN/fullchain.pem
sslProtocol 24
ciphers TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:ECDHE+AESGCM:ECDHE+CHACHA20
enableECDHE 1
enableSpdy 15
map PRIMARY_HOST PRIMARY_DOMAIN
}
LISTENERS_REF
sed -i "s|PRIMARY_DOMAIN|${PRIMARY_DOMAIN}|g; s|PRIMARY_HOST|${PRIMARY_DOMAIN}|g" /usr/local/lsws/conf/httpd_config.conf
echo "==> Setting systemd LimitNOFILE for lsws"
mkdir -p /etc/systemd/system/lsws.service.d
cat > /etc/systemd/system/lsws.service.d/override.conf <<'LSWS_OVERRIDE'
[Service]
LimitNOFILE=200000
LimitNPROC=16384
LSWS_OVERRIDE
systemctl daemon-reload
echo "==> Installing acme.sh and issuing Let's Encrypt cert"
curl -s https://get.acme.sh | sh -s email="${ACME_EMAIL}"
export PATH="/root/.acme.sh:${PATH}"
/root/.acme.sh/acme.sh --set-default-ca --server letsencrypt
# Stop OLS briefly so acme.sh standalone can bind :80 (or use webroot if ports are critical)
systemctl stop lsws || true
/root/.acme.sh/acme.sh --issue --standalone -d "${PRIMARY_DOMAIN}" --keylength ec-256 --force || \
/root/.acme.sh/acme.sh --issue --standalone -d "${PRIMARY_DOMAIN}" --keylength 2048 --force
# Install cert into /etc/letsencrypt/live/${PRIMARY_DOMAIN}/ layout the listener expects
mkdir -p "/etc/letsencrypt/live/${PRIMARY_DOMAIN}"
/root/.acme.sh/acme.sh --install-cert -d "${PRIMARY_DOMAIN}" \
--key-file "/etc/letsencrypt/live/${PRIMARY_DOMAIN}/privkey.pem" \
--fullchain-file "/etc/letsencrypt/live/${PRIMARY_DOMAIN}/fullchain.pem" \
--reloadcmd "touch /usr/local/lsws/conf/serial.no && systemctl reload lsws"
echo "==> Validating OpenLiteSpeed config"
/usr/local/lsws/bin/lswsctrl -t || true
echo "==> Starting OpenLiteSpeed"
systemctl enable --now lsws
systemctl restart lsws
echo "==> Waiting for listeners on :80 and :443"
for i in {1..30}; do
if ss -lntp | grep -q ':443' && ss -lntp | grep -q ':80'; then
break
fi
sleep 1
done
if ! ss -lntp | grep -q ':443'; then
echo "OLS did not bind :443"
/usr/local/lsws/bin/lswsctrl status || true
tail -100 /usr/local/lsws/logs/error.log || true
exit 1
fi
echo
echo "========================================"
echo "DONE"
echo "========================================"
echo
echo "Kernel:"
uname -r
echo
echo "Listeners:"
ss -lntp | grep -E ':(80|443|7080)\b' || true
echo
echo "Services:"
systemctl is-active lsws firewalld fail2ban chronyd || true
echo
echo "OLS version:"
/usr/local/lsws/bin/lshttpd -v 2>&1 | head -2
echo
echo "WebAdmin: https://127.0.0.1:7080/ (SSH-tunnel from your workstation)"
echo " user: ${ADMIN_USER}"
echo
echo "First test:"
echo " curl -I https://${PRIMARY_DOMAIN}/"
echo
echo "WordPress site root: ${VHROOT}/html (deploy WP files there, then install LSCache plugin)"
echo "Cache path: ${VHROOT}/cache"
echo
echo "Cert renewal hook installed via acme.sh; renewal runs daily."
Rendez-le exécutable et lancez-le (exportez d’abord les quatre variables d’environnement requises) :
chmod 700 /root/setup-openlitespeed-alma9.sh
export PRIMARY_DOMAIN=example.com
export ACME_EMAIL=ops@example.com
export ADMIN_USER=opsadmin
export ADMIN_PASSWORD=...
/root/setup-openlitespeed-alma9.sh
Tunnellisez vers le WebAdmin depuis votre poste (ssh -L 7080:127.0.0.1:7080 root@host), ouvrez https://127.0.0.1:7080/, déposez WordPress sous /var/www/<domaine>/html, puis installez le plugin officiel LSCache pour WordPress et confirmez X-LiteSpeed-Cache: hit au deuxième chargement de page. Le script ne configure pas de sauvegardes au niveau hôte — l’hypothèse est que la VM a des instantanés/sauvegardes au niveau cloud.
Pour le parc WordPress de bout en bout (réglage LSCache, déploiements de plugins, cadence de certificats, patching), Stack Harbor le possède en Environnements infogérés (Environnements infogérés) — réservez une revue.