Zum Inhalt springen

WordPress auf RHEL

WordPress benötigt einen LAMP-Stack: Apache als Webserver, MariaDB als Datenbank und PHP als Laufzeitumgebung. Auf RHEL kommt erschwerend hinzu, dass SELinux mitdenkt — und konfiguriert werden muss.

Browser → Apache (httpd) → PHP-FPM → WordPress
MariaDB
Terminal-Fenster
sudo dnf install httpd mariadb-server php php-mysqlnd php-fpm \
php-json php-xml php-mbstring php-gd php-zip php-curl

PHP-Version prüfen (WordPress empfiehlt ≥ 8.1):

Terminal-Fenster
php -v

Neuere PHP-Versionen über das Remi-Repository:

Terminal-Fenster
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
sudo dnf module switch-to php:remi-8.3
Terminal-Fenster
sudo systemctl enable --now httpd
sudo systemctl enable --now mariadb
sudo systemctl enable --now php-fpm
Terminal-Fenster
sudo mysql_secure_installation
# → root-Passwort setzen, anonyme Benutzer entfernen,
# Remote-Root deaktivieren, Test-Datenbank entfernen
Terminal-Fenster
sudo mysql -u root -p
CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'sicheres-passwort';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Terminal-Fenster
cd /var/www/html
sudo curl -O https://wordpress.org/latest.tar.gz
sudo tar -xzf latest.tar.gz
sudo rm latest.tar.gz
# Eigenes Verzeichnis (empfohlen statt Webroot direkt)
sudo mv wordpress /var/www/html/wordpress
Terminal-Fenster
sudo cp /var/www/html/wordpress/wp-config-sample.php \
/var/www/html/wordpress/wp-config.php
sudo nano /var/www/html/wordpress/wp-config.php

Folgende Werte anpassen:

define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', 'sicheres-passwort' );
define( 'DB_HOST', 'localhost' );

Außerdem die Security Keys ersetzen — frische Werte von: https://api.wordpress.org/secret-key/1.1/salt/

Terminal-Fenster
sudo chown -R apache:apache /var/www/html/wordpress
sudo find /var/www/html/wordpress -type d -exec chmod 755 {} \;
sudo find /var/www/html/wordpress -type f -exec chmod 644 {} \;
Terminal-Fenster
sudo nano /etc/httpd/conf.d/wordpress.conf
<VirtualHost *:80>
ServerName wordpress.example.com
DocumentRoot /var/www/html/wordpress
<Directory /var/www/html/wordpress>
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/wordpress-error.log
CustomLog /var/log/httpd/wordpress-access.log combined
</VirtualHost>
Terminal-Fenster
sudo apachectl configtest # Syntax prüfen
sudo systemctl reload httpd

SELinux blockiert auf RHEL standardmäßig, was httpd schreiben und auf das Netz zugreifen darf. WordPress benötigt beides:

Terminal-Fenster
# Apache darf Dateien schreiben (für Updates, Uploads)
sudo setsebool -P httpd_unified 1
# Apache darf Netzwerkverbindungen aufbauen (für APIs, Update-Checks)
sudo setsebool -P httpd_can_network_connect 1
# Korrekte SELinux-Kontexte für WordPress-Verzeichnis setzen
sudo semanage fcontext -a -t httpd_sys_rw_content_t \
"/var/www/html/wordpress/wp-content(/.*)?"
sudo restorecon -Rv /var/www/html/wordpress
Terminal-Fenster
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Browser öffnen: http://wordpress.example.com

Der WordPress-Installationsassistent führt durch die abschließende Einrichtung (Seitentitel, Admin-Konto).

Für sprechende URLs muss mod_rewrite in Apache aktiv sein und .htaccess-Dateien erlaubt werden — das AllowOverride All im VirtualHost oben deckt das bereits ab:

Terminal-Fenster
sudo dnf install mod_rewrite # falls nicht vorhanden
sudo systemctl restart httpd

Dann in WordPress: Einstellungen → Permalinks → gewünschte Struktur wählen und speichern.