Installation von WordPress


Diese Installation läuft auf einem virtuellen Ubuntu Linux Server, der bei Strato gehostet wird. Das System läuft auf einem LEMP-Stack und ist erstmal eine Standardinstallation.

Der Server hatte schon ein Certbot-Zertifikat für die HTTPS-Verbindung aus früheren Tests, das ich weiter verwende. An der Stelle sei Euch Cerbot aber sehr ans Herz gelegt.

Nginx lief schon. Die Installation überspringe ich daher an dieser Stelle auch.

Folgende Schritte habe ich zudem ausgeführt und mich dabei an der Anleitung von Xiao Guoan bzw. JournalDev orientiert.

  1. Ubuntu Paketverwaltung aktualisieren
sudo apt-get update
sudo apt-get upgrade

2. Installation von MariaDB plus Absicherung des Servers. Dabei habe ich auch gleich das root-Passwort vergeben.

sudo apt-get install mariadb-server
sudo mysql_secure_installation

Anlage der Datenbanken und des wordpress-users:

sudo mysql -u root -p
MariaDB [mysql]> CREATE DATABASE wordpress_db;
MariaDB [mysql]> GRANT ALL ON wordpress_db.* TO 'wpuser'@'localhost' IDENTIFIED BY 'Passw0rd!' WITH GRANT OPTION;
MariaDB [mysql]> FLUSH PRIVILEGES;
MariaDB [mysql]> exit

3. Installation der php-Pakete

sudo apt-get install php7.2 php7.2-cli php7.2-fpm php7.2-mysql php7.2-json php7.2-opcache php7.2-mbstring php7.2-xml php7.2-gd php7.2-curl

4. Anpassung der nginx-Konfiguration

sudo mkdir -p /var/www/html/wordpress/public_html
sudo nano /etc/nginx/sites-available/wordpress.conf

In der Conf-Datei dann entsprechend die Server-Einträge vornehmen. Ich habe das entsprechend in den bereits vorhandenen Block für die ssl-Konfigation eingebettet

server {
    if ($host = blog.kocherscheidt.org) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    server_name SUBDOMAIN.DOMAIN.LTD;
    return 404; # managed by Certbot


}


server {
            listen 443 ssl; # managed by Certbot
            ssl_certificate /etc/letsencrypt/live/SUBDOMAIN.DOMAIN.LTD/fullchain.pem; # managed by Certbot
            ssl_certificate_key /etc/letsencrypt/live/SUBDOMAIN.DOMAIN.LTD/privkey.pem; # managed by Certbot
            include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
            ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
            root /var/www/html/wordpress/public_html;
            index index.php index.html;
            server_name SUBDOMAIN.DOMAIN.LTD;

            access_log /var/log/nginx/SUBDOMAIN.access.log;
            error_log /var/log/nginx/SUBDOMAIN.error.log;

            location / {
                         try_files $uri $uri/ =404;
            }

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

            location ~ /\.ht {
                         deny all;
            }

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

            location = /robots.txt {
                         allow all;
                         log_not_found off;
                         access_log off;
           }

            location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {



            location / {
                         try_files $uri $uri/ =404;
            }

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

            location ~ /\.ht {
                         deny all;
            }

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

            location = /robots.txt {
                         allow all;
                         log_not_found off;
                         access_log off;
           }

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

Konfiguration dann über einen Symlink für nginx aktivieren

cd /etc/nginx/sites-enabled
sudo ln -s ../sites-available/wordpress.conf

nginx testen und bei Erfolg neu starten

sudo nginx -t
sudo systemctl restart nginx

5. WordPress runterladen, entpacken und verschieben

cd /var/www/html/wordpress/public_html
sudo wget https://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
mv wordpress/* .
rm -rf wordpress

WordPress Konfig-File anpassen und Datenbankeinstellungen übernehmen.


/var/www/html/wordpress/public_html
sudo cp wp-config-sample.php wp-config.php
sudo nano wp-config.php


 ...
 ...
 define('DB_NAME', 'wordpress_db');
 define('DB_USER', 'wpuser');
 define('DB_PASSWORD', 'Passw0rd!');
 ...
 ...

Danach kann die Installation auf der WordPress-Seite SUBDOMAIN.DOMAIN.TLD abgeschlossen werde.