CMS/WordPress

WordPress-Datenbank auf Ubuntu einrichten

Um eine WordPress-Datenbank auf einem Ubuntu-Rechner einzurichten, folge diesen Schritten:

1. MySQL-Konsole öffnen

sudo mysql -u root -p

2. Datenbank anlegen

CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

3. Benutzer anlegen

CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'dein_passwort';

4. Rechte vergeben

GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

WordPress herunterladen

cd $HOME
wget https://wordpress.org/latest.tar.gz
sudo tar -xzf latest.tar.gz -C /var/www

Dateirechte für WordPress setzen

sudo chown -R www-data:www-data /var/www/wordpress

Nginx für WordPress konfigurieren

Erstelle eine neue Konfigurationsdatei für deine WordPress-Seite:

sudo nano /etc/nginx/conf.d/wordpress.conf

Füge folgenden Inhalt ein:

server {
    listen 80;
    server_name wordpress.localhost;
    root /var/www/wordpress;

    index index.php index.html index.htm;

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

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

    location ~ /\.ht {
        deny all;
    }
}

Aktiviere die Konfiguration:

sudo nginx -t
sudo systemctl reload nginx

WordPress auf Produktionsserver übertragen (ohne wp-config.php)

Um deine WordPress-Installation (ohne Einstellungen wie `wp-config.php`) auf einen Produktionsserver zu übertragen, verwende folgenden Befehl:

rsync -avz --exclude='wp-config.php' /var/www/wordpress/ benutzername@server:/var/www/wordpress/

Ersetze `benutzername@server` durch deinen Benutzernamen und die Adresse deines Produktionsservers. Der Parameter `--exclude='wp-config.php'` sorgt dafür, dass die Konfigurationsdatei nicht übertragen wird.

Produktionsserver Nginx-Einstellung

Nginx für WordPress konfigurieren

Erstelle eine neue Konfigurationsdatei für deine WordPress-Seite:

sudo nano /etc/nginx/conf.d/wordpress.conf

Füge folgenden Inhalt ein:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name wordpress.ahrensburg.city;
    root /var/www/wordpress;
    ssl_certificate /etc/letsencrypt/live/ahrensburg.city/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/ahrensburg.city/privkey.pem;

    index index.php index.html index.htm;

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

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

    location ~ /\.ht {
        deny all;
    }
}

Aktiviere die Konfiguration:

sudo nginx -t
sudo systemctl reload nginx

Kategorien: Keine
Zuletzt aktualisiert am 28.01.2026 03:23