CMS/WordPress: Unterschied zwischen den Versionen

Aus Dokument
Zur Navigation springen Zur Suche springen
imported>Import
Version 151
// via Wikitext Extension for VSCode
 
Zeile 7: Zeile 7:


=== 1. MySQL-Konsole öffnen ===
=== 1. MySQL-Konsole öffnen ===
<syntaxhighlight lang="bash">
sudo mysql -u root -p
</syntaxhighlight>


<syntaxhighlight lang="bash">sudo mysql -u root -p</syntaxhighlight>
=== 2. Datenbank anlegen ===
=== 2. Datenbank anlegen ===
<syntaxhighlight lang="sql">
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
</syntaxhighlight>


<syntaxhighlight lang="sql">CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;</syntaxhighlight>
=== 3. Benutzer anlegen ===
=== 3. Benutzer anlegen ===
<syntaxhighlight lang="sql">
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'dein_passwort';
</syntaxhighlight>


<syntaxhighlight lang="sql">CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'dein_passwort';</syntaxhighlight>
=== 4. Rechte vergeben ===
=== 4. Rechte vergeben ===
<syntaxhighlight lang="sql">
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
</syntaxhighlight>


<syntaxhighlight lang="sql">GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;</syntaxhighlight>
== WordPress herunterladen ==
== WordPress herunterladen ==
<pre>
cd $HOME
wget https://wordpress.org/latest.tar.gz
sudo tar -xzf latest.tar.gz -C /var/www
</pre>


<pre>cd $HOME
wget https://wordpress.org/latest.tar.gz
sudo tar -xzf latest.tar.gz -C /var/www</pre>
== Dateirechte für WordPress setzen ==
== Dateirechte für WordPress setzen ==
<pre>
sudo chown -R www-data:www-data /var/www/wordpress
</pre>


<pre>sudo chown -R www-data:www-data /var/www/wordpress</pre>
== Nginx für WordPress konfigurieren ==
== Nginx für WordPress konfigurieren ==
Erstelle eine neue Konfigurationsdatei für deine WordPress-Seite:


Erstelle eine neue Konfigurationsdatei für deine WordPress-Seite:
<pre>
sudo nano /etc/nginx/conf.d/wordpress.conf
</pre>


<pre>sudo nano /etc/nginx/conf.d/wordpress.conf</pre>
Füge folgenden Inhalt ein:
Füge folgenden Inhalt ein:


<syntaxhighlight lang="nginx">server {
<syntaxhighlight lang="nginx">
server {
     listen 80;
     listen 80;
     server_name wordpress.localhost;
     server_name wordpress.localhost;
Zeile 54: Zeile 69:
         deny all;
         deny all;
     }
     }
}</syntaxhighlight>
}
</syntaxhighlight>
 
Aktiviere die Konfiguration:
Aktiviere die Konfiguration:


<syntaxhighlight lang="bash">sudo nginx -t
<syntaxhighlight lang="bash">
sudo systemctl reload nginx</syntaxhighlight>
sudo nginx -t
sudo systemctl reload nginx
</syntaxhighlight>
 
== WordPress auf Produktionsserver übertragen (ohne wp-config.php) ==
== 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:
Um deine WordPress-Installation (ohne Einstellungen wie `wp-config.php`) auf einen Produktionsserver zu übertragen, verwende folgenden Befehl:


<syntaxhighlight lang="bash">rsync -avz --exclude='wp-config.php' /var/www/wordpress/ benutzername@server:/var/www/wordpress/</syntaxhighlight>
<syntaxhighlight lang="bash">
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.
rsync -avz --exclude='wp-config.php' /var/www/wordpress/ benutzername@server:/var/www/wordpress/
</syntaxhighlight>
 
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 ==
== Produktionsserver Nginx-Einstellung ==


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


Erstelle eine neue Konfigurationsdatei für deine WordPress-Seite:
<pre>
sudo nano /etc/nginx/conf.d/wordpress.conf
</pre>


<pre>sudo nano /etc/nginx/conf.d/wordpress.conf</pre>
Füge folgenden Inhalt ein:
Füge folgenden Inhalt ein:


<syntaxhighlight lang="nginx">server {
<syntaxhighlight lang="nginx">
server {
     listen 443 ssl http2;
     listen 443 ssl http2;
     listen [::]:443 ssl http2;
     listen [::]:443 ssl http2;
Zeile 98: Zeile 125:
         deny all;
         deny all;
     }
     }
}</syntaxhighlight>
}
</syntaxhighlight>
 
Aktiviere die Konfiguration:
Aktiviere die Konfiguration:


<syntaxhighlight lang="bash">sudo nginx -t
<syntaxhighlight lang="bash">
sudo systemctl reload nginx</syntaxhighlight>
sudo nginx -t
sudo systemctl reload nginx
</syntaxhighlight>


----
----
''Hinweis: Diese Inhalte wurden mit Unterstützung von Künstlicher Intelligenz erstellt und redaktionell überprüft (Transparenzhinweis gemäß Art. 50 EU AI Act).''
''Hinweis: Diese Inhalte wurden mit Unterstützung von Künstlicher Intelligenz erstellt und redaktionell überprüft (Transparenzhinweis gemäß Art. 50 EU AI Act).''

Aktuelle Version vom 28. Januar 2026, 03:23 Uhr

Hinweis: Diese Inhalte wurden mit Unterstützung von Künstlicher Intelligenz erstellt und redaktionell überprüft (Transparenzhinweis gemäß Art. 50 EU AI Act).


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

Hinweis: Diese Inhalte wurden mit Unterstützung von Künstlicher Intelligenz erstellt und redaktionell überprüft (Transparenzhinweis gemäß Art. 50 EU AI Act).