LiteSpeed ist ein ereignisbasierter, hochperformanter Webserver. Er ist vollständig kompatibel mit Apache-Konfigurationen und bietet deutlich bessere Performance, besonders für PHP-Anwendungen.
LiteSpeed Varianten
Übersicht
| Variante | Lizenz | Features | |----------|--------|----------| | OpenLiteSpeed | Open Source (GPLv3) | Kostenlos, Community | | LiteSpeed Enterprise | Kommerziell | Mehr Features, Support | | LSWS Standard | Kommerziell | Für cPanel/Plesk |
Vorteile
- Event-basierte Architektur
- Apache .htaccess-kompatibel
- Integrierter PHP-Handler (LSPHP)
- Eingebauter Cache (LSCache)
- HTTP/2 und HTTP/3 (QUIC)
- WebAdmin GUI
- mod_security kompatibelOpenLiteSpeed Installation
Repository-Installation (Debian/Ubuntu)
# Repository hinzufügen
wget -O - https://repo.litespeed.sh | bash
# Installation
apt update
apt install openlitespeed
# PHP installieren
apt install lsphp82 lsphp82-mysql lsphp82-curl lsphp82-commonRepository-Installation (CentOS/AlmaLinux)
# Repository hinzufügen
rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.3-1.el8.noarch.rpm
# Installation
dnf install openlitespeed
# PHP installieren
dnf install lsphp82 lsphp82-mysql lsphp82-curlSkript-Installation
# Ein-Klick-Installation
wget https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh
chmod +x ols1clk.sh
./ols1clk.shService starten
# OpenLiteSpeed starten
/usr/local/lsws/bin/lswsctrl start
# Status prüfen
/usr/local/lsws/bin/lswsctrl status
# Systemd
systemctl enable lsws
systemctl start lswsWeb Admin Interface
Zugang einrichten
# Admin-Passwort setzen
/usr/local/lsws/admin/misc/admpass.sh
# Eingabe:
# Username: admin
# Password: <sicheres-passwort>Zugriff
URL: https://server-ip:7080Firewall öffnen
# UFW
ufw allow 7080/tcp
# firewalld
firewall-cmd --add-port=7080/tcp --permanent
firewall-cmd --reloadKonfigurationsdateien
Struktur
/usr/local/lsws/
├── conf/
│ ├── httpd_config.conf # Hauptkonfiguration
│ └── vhosts/
│ └── Example/
│ └── vhconf.conf # Virtual Host
├── lsphp82/ # PHP-Handler
├── logs/ # Log-Dateien
├── admin/ # Admin-Interface
└── html/ # Default-DocrootHauptkonfiguration
# /usr/local/lsws/conf/httpd_config.conf
serverName server.example.com
user nobody
group nogroup
priority 0
autoRestart 1
chrootPath /
enableChroot 0
inMemBufSize 60M
swappingDir /tmp/lshttpd/swap
# Listener
listener Default {
address *:80
secure 0
map Example *
}
# SSL Listener
listener SSL {
address *:443
secure 1
keyFile /etc/letsencrypt/live/example.com/privkey.pem
certFile /etc/letsencrypt/live/example.com/fullchain.pem
map Example *
}Virtual Host Konfiguration
# /usr/local/lsws/conf/vhosts/Example/vhconf.conf
docRoot /var/www/html
vhDomain example.com
vhAliases www.example.com
enableGzip 1
enableBr 1
index {
useServer 0
indexFiles index.php, index.html
}
context / {
location $DOC_ROOT/
allowBrowse 1
rewrite {
enable 1
rules <<<END_rules
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
END_rules
}
}
# PHP-Handler
scripthandler {
add lsapi:lsphp82 php
}
extprocessor lsphp82 {
type lsapi
address uds://tmp/lshttpd/lsphp82.sock
maxConns 35
env PHP_LSAPI_CHILDREN=35
initTimeout 60
retryTimeout 0
persistConn 1
respBuffer 0
autoStart 2
path /usr/local/lsws/lsphp82/bin/lsphp
memSoftLimit 2047M
memHardLimit 2047M
procSoftLimit 1400
procHardLimit 1500
}PHP mit LiteSpeed
LSPHP installieren
# Debian/Ubuntu
apt install lsphp82 lsphp82-common lsphp82-mysql lsphp82-curl lsphp82-gd lsphp82-imagick lsphp82-intl lsphp82-mbstring lsphp82-xml lsphp82-zip
# PHP-Version verlinken
ln -sf /usr/local/lsws/lsphp82/bin/lsphp /usr/local/lsws/fcgi-bin/lsphpPHP-Konfiguration
# /usr/local/lsws/lsphp82/etc/php/8.2/litespeed/php.ini
max_execution_time = 120
max_input_time = 60
memory_limit = 256M
post_max_size = 64M
upload_max_filesize = 64M
date.timezone = Europe/Berlin
# OPcache
opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000PHP-Version wechseln
# Im WebAdmin: Server Configuration → External App
# Oder per Konfiguration
extprocessor lsphp {
type lsapi
address uds://tmp/lshttpd/lsphp.sock
path /usr/local/lsws/lsphp82/bin/lsphp
}LSCache
LiteSpeed Cache aktivieren
# Im WebAdmin: Virtual Hosts → Cache → Enable Cache
# Oder in vhconf.conf:
cacheStoreRoot /usr/local/lsws/cachedata/$VH_NAME/
cache {
enable 1
maxCacheObjSize 10M
maxStaleAge 200
qsCache 1
reqCookieCache 1
respCookieCache 1
ignoreReqCacheCtrl 1
ignoreRespCacheCtrl 0
}WordPress LSCache Plugin
# Plugin-Verzeichnis
cd /var/www/html/wp-content/plugins
wget https://downloads.wordpress.org/plugin/litespeed-cache.latest-stable.zip
unzip litespeed-cache.latest-stable.zip
rm litespeed-cache.latest-stable.zip
# In WordPress aktivieren
# Plugins → LiteSpeed Cache → AktivierenCache-Regeln
# .htaccess (WordPress)
# Cache TTL
<IfModule LiteSpeed>
CacheLookup on
RewriteEngine On
RewriteRule .* - [E=Cache-Control:max-age=3600]
</IfModule>
# Seiten nicht cachen
<IfModule LiteSpeed>
RewriteRule ^wp-admin - [E=Cache-Control:no-cache]
RewriteRule ^wp-login\.php - [E=Cache-Control:no-cache]
</IfModule>SSL/TLS
Let's Encrypt mit Certbot
# Certbot installieren
apt install certbot
# Zertifikat anfordern (Webroot)
certbot certonly --webroot -w /var/www/html -d example.com -d www.example.comSSL-Listener konfigurieren
# In httpd_config.conf
listener SSL {
address *:443
secure 1
keyFile /etc/letsencrypt/live/example.com/privkey.pem
certFile /etc/letsencrypt/live/example.com/fullchain.pem
CACertFile /etc/letsencrypt/live/example.com/chain.pem
sslProtocol 24
enableECDHE 1
renegProtection 1
sslSessionCache 1
sslSessionTickets 1
enableSpdy 15
enableQuic 1
map Example *
}HTTP/3 (QUIC) aktivieren
# In listener SSL
enableQuic 1
# Firewall für UDP
ufw allow 443/udp.htaccess-Kompatibilität
Apache-Regeln übernehmen
# .htaccess (funktioniert mit LiteSpeed)
RewriteEngine On
RewriteBase /
# HTTPS erzwingen
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# WordPress Permalinks
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]LiteSpeed-spezifische Direktiven
# .htaccess
<IfModule LiteSpeed>
# Cache aktivieren
CacheLookup on
# Cache-Header
RewriteEngine On
RewriteRule .* - [E=Cache-Control:max-age=3600]
# Kompression
CacheCompress on
</IfModule>Performance-Tuning
Connection-Limits
# httpd_config.conf
maxConnections 10000
maxSSLConnections 10000
connTimeout 300
maxKeepAliveReq 10000
keepAliveTimeout 5Worker-Konfiguration
# Server Process
serverProcess {
priority 0
CPUAffinity 0
}Cache-Tuning
# In vhconf.conf
cache {
enable 1
maxCacheObjSize 100M
storagePath /tmp/lscache/$VH_NAME/
privateCache 1
checkPrivateCache 1
checkPublicCache 1
maxStaleAge 86400
}Migration von Apache
Apache-Konfiguration übernehmen
# OpenLiteSpeed kann httpd.conf lesen
# In WebAdmin: Tools → Apache Conf Parser
# Manuell:
# 1. Virtual Hosts erstellen
# 2. DocumentRoot setzen
# 3. .htaccess Regeln prüfenDienst wechseln
# Apache stoppen
systemctl stop apache2
systemctl disable apache2
# LiteSpeed starten
systemctl enable lsws
systemctl start lsws
# Ports prüfen
ss -tlnp | grep -E ':80|:443'WordPress optimieren
Komplettes Setup
# 1. OpenLiteSpeed + LSPHP
apt install openlitespeed lsphp82 lsphp82-mysql lsphp82-curl lsphp82-gd lsphp82-imagick
# 2. MariaDB
apt install mariadb-server
mysql_secure_installation
# 3. WordPress herunterladen
cd /usr/local/lsws/html
wget https://wordpress.org/latest.tar.gz
tar xzf latest.tar.gz
mv wordpress/* .
rm -rf wordpress latest.tar.gz
chown -R nobody:nogroup /usr/local/lsws/htmlLSCache-Plugin Einstellungen
Dashboard → LiteSpeed Cache → Cache
- Enable Cache: On
- Cache Logged-in Users: Off
- Cache Commenters: Off
- Cache REST API: On
- TTL: 604800 (1 Woche)
Page Optimization:
- CSS Minify: On
- JS Minify: On
- HTML Minify: On
- Load CSS Asynchronously: OnTroubleshooting
Logs prüfen
# Error Log
tail -f /usr/local/lsws/logs/error.log
# Access Log
tail -f /usr/local/lsws/logs/access.log
# PHP-Fehler
tail -f /usr/local/lsws/logs/lsphp.stderr.logKonfiguration testen
# Syntax prüfen
/usr/local/lsws/bin/lswsctrl configtest
# Graceful Restart
/usr/local/lsws/bin/lswsctrl restartHäufige Probleme
# PHP-Handler startet nicht
# → PHP-Pfad prüfen
ls -la /usr/local/lsws/lsphp82/bin/lsphp
# 503-Fehler
# → External App Connections erhöhen
maxConns 50
env PHP_LSAPI_CHILDREN=50
# Cache funktioniert nicht
# → Cache-Verzeichnis prüfen
ls -la /usr/local/lsws/cachedata/Zusammenfassung
| Komponente | Pfad | |------------|------| | Installation | /usr/local/lsws/ | | Konfiguration | /usr/local/lsws/conf/ | | Logs | /usr/local/lsws/logs/ | | PHP | /usr/local/lsws/lsphp82/ | | Cache | /usr/local/lsws/cachedata/ |
| Befehl | Funktion | |--------|----------| | lswsctrl start | Starten | | lswsctrl stop | Stoppen | | lswsctrl restart | Neustart | | lswsctrl configtest | Konfig prüfen |
| Feature | Vorteil | |---------|---------| | LSAPI | Schneller als PHP-FPM | | LSCache | Integrierter Page-Cache | | HTTP/3 | QUIC-Unterstützung | | .htaccess | Apache-kompatibel |
Fazit
LiteSpeed bietet deutlich bessere Performance als Apache, besonders für PHP-Anwendungen. Die .htaccess-Kompatibilität erleichtert die Migration. Der integrierte LSCache macht externe Caching-Lösungen oft überflüssig. OpenLiteSpeed ist eine exzellente kostenlose Option für WordPress und andere PHP-Anwendungen. Das WebAdmin-Interface vereinfacht die Konfiguration erheblich.