Linux VPS

WordPress auf dem VPS installieren

WordPress auf einem HolyCloud VPS mit Nginx, MariaDB und PHP-FPM bereitstellen; optional mit WP-CLI.

~18 Minuten Lesezeit Dazwischenliegend #wordpress#nginx#mariadb#wp-cli

Dieser Leitfaden stellt WordPress auf einem HolyCloud Linux-VPS mit Nginx, MariaDB und PHP-FPM bereit. WP-CLI beschleunigt Installation und Updates über die Kommandozeile.

Voraussetzungen

  • HolyCloud VPS (mindestens 2 GB RAM empfohlen)
  • Domain, die auf die IP des VPS zeigt (A-Eintrag)
  • Ubuntu 22.04/24.04 oder Debian 12, sudo-Zugriff
  • Ports 80 und 443 offen (UFW + HolyCloud-Panel)

Tipp: Erstellen Sie vor der Inbetriebnahme einen HolyCloud-Snapshot.

Schritt 1: Basispakete

sudo apt update
sudo apt upgrade -y
sudo apt install -y nginx mariadb-server php8.3-fpm php8.3-mysql php8.3-xml php8.3-curl \
  php8.3-mbstring php8.3-zip php8.3-gd php8.3-intl certbot python3-certbot-nginx

Falls PHP 8.3 nicht verfügbar ist, fügen Sie das Sury/ondrej-Repository hinzu (siehe den Leitfaden zu PHP/Composer) und führen Sie apt install anschließend erneut aus.

Schritt 2: MariaDB absichern

sudo mysql_secure_installation

Legen Sie die WordPress-Datenbank und den Benutzer an:

sudo mysql <<'EOF'
CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'MotDePasseBDDFort!';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EOF

Schritt 3: WordPress herunterladen

cd /tmp
curl -LO https://wordpress.org/latest.tar.gz
sudo tar -xzf latest.tar.gz -C /var/www/
sudo chown -R www-data:www-data /var/www/wordpress
sudo find /var/www/wordpress -type d -exec chmod 755 {} \;
sudo find /var/www/wordpress -type f -exec chmod 644 {} \;

Konfigurieren Sie wp-config.php:

cd /var/www/wordpress
sudo -u www-data cp wp-config-sample.php wp-config.php
sudo -u www-data sed -i "s/database_name_here/wordpress/" wp-config.php
sudo -u www-data sed -i "s/username_here/wpuser/" wp-config.php
sudo -u www-data sed -i "s/password_here/MotDePasseBDDFort!/" wp-config.php

Sicherheitsschlüssel (erzeugen unter https://api.wordpress.org/secret-key/1.1/salt/):

curl -s https://api.wordpress.org/secret-key/1.1/salt/ | sudo -u www-data tee /tmp/salts.txt
# Insérez le contenu dans wp-config.php à la place des define('AUTH_KEY'...)

Schritt 4: virtueller Host in Nginx

sudo nano /etc/nginx/sites-available/wordpress
server {
    listen 80;
    server_name blog.example.com;
    root /var/www/wordpress;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
        expires max;
        log_not_found off;
    }

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt  { log_not_found off; access_log off; }
}

Aktivieren Sie die Website:

sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Let's-Encrypt-Zertifikat:

sudo certbot --nginx -d blog.example.com

Schritt 5: WP-CLI (optional)

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
wp --info

Vollständige Installation über die CLI:

cd /var/www/wordpress
sudo -u www-data wp core install \
  --url="https://blog.example.com" \
  --title="Mon site HolyCloud" \
  --admin_user="admin" \
  --admin_password="MotDePasseAdminFort!" \
  --admin_email="[email protected]"

Aktualisierungen:

sudo -u www-data wp core update
sudo -u www-data wp plugin update --all

Schritt 6: schnelle Absicherung

sudo -u www-data wp config set DISALLOW_FILE_EDIT true --raw
sudo apt install -y fail2ban

Berechtigungen für Uploads:

sudo -u www-data mkdir -p /var/www/wordpress/wp-content/uploads

Überprüfung

  • Öffnen Sie https://blog.example.com – Installer oder Live-Website
  • sudo -u www-data wp option get siteurl (mit WP-CLI)
  • sudo systemctl status nginx mariadb php8.3-fpm

Benötigen Sie Hilfe?

Der HolyCloud-Support hilft bei der Konnektivität und beim VPS; für WordPress-Themes und -Plugins ist der jeweilige Hersteller zuständig.