Node.js App deployen: PM2 und Nginx Anleitung
Vollständige Anleitung zum Deployen von Node.js-Anwendungen auf einem VPS. Node.js-Installation mit nvm, PM2 Process Manager, Nginx Reverse Proxy, SSL-Zertifikat und Umgebungsvariablen.
Anleitung zur Installation und Optimierung von WordPress auf einem VPS. LEMP Stack Setup, wp-config.php Einstellungen, Dateiberechtigungen, SSL, OPcache Performance-Optimierung und Sicherheitshärtung.
WordPress ist das weltweit am häufigsten verwendete Content-Management-System. WordPress auf einem VPS statt auf Shared Hosting zu betreiben bietet mehr Kontrolle, bessere Performance und Anpassungsmöglichkeiten. Diese Anleitung behandelt WordPress-Installation, Konfiguration und Optimierung auf einem LEMP Stack.
# Systemaktualisierung
sudo apt update && sudo apt upgrade -y
# Nginx installieren
sudo apt install nginx -y
sudo systemctl enable nginx
# MariaDB installieren
sudo apt install mariadb-server -y
sudo systemctl enable mariadb
sudo mysql_secure_installation
# PHP 8.2 und erforderliche Erweiterungen für WordPress
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
sudo apt install php8.2 php8.2-fpm php8.2-mysql php8.2-xml php8.2-curl \
php8.2-mbstring php8.2-zip php8.2-gd php8.2-imagick php8.2-intl \
php8.2-bcmath php8.2-soap -y
sudo systemctl enable php8.2-fpm
CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'starkes-passwort';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
sudo mv wordpress /var/www/mysite.com
# Dateiberechtigungen setzen
sudo chown -R www-data:www-data /var/www/mysite.com
sudo find /var/www/mysite.com -type d -exec chmod 755 {} \;
sudo find /var/www/mysite.com -type f -exec chmod 644 {} \;
// Datenbankeinstellungen
define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', 'starkes-passwort' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8mb4' );
// Dateibearbeitung deaktivieren (Sicherheit)
define('DISALLOW_FILE_EDIT', true);
// SSL erzwingen
define('FORCE_SSL_ADMIN', true);
// Speicherlimit
define('WP_MEMORY_LIMIT', '256M');
server {
listen 80;
server_name mysite.com www.mysite.com;
root /var/www/mysite.com;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location = /xmlrpc.php { deny all; }
location = /wp-config.php { deny all; }
location ~ /\. { deny all; }
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff|woff2|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
client_max_body_size 64M;
}
sudo ln -s /etc/nginx/sites-available/mysite.com /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d mysite.com -d www.mysite.com
opcache.enable = 1
opcache.memory_consumption = 256
opcache.max_accelerated_files = 10000
opcache.revalidate_freq = 2
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_vars = 3000
# wp-config.php absichern
sudo chmod 600 /var/www/mysite.com/wp-config.php
Setzen Sie die Berechtigungen von wp-config.php auf 600. Diese Datei enthält Ihr Datenbankpasswort.
Auf REXE-Servern werden für WordPress mindestens 2 GB RAM empfohlen. Für stark frequentierte Websites bevorzugen Sie 4 GB+ RAM und SSD-Speicher.
Ihre WordPress-Website läuft jetzt auf einem LEMP Stack auf einem VPS, ist mit SSL gesichert und mit OPcache optimiert. Halten Sie Ihre Website mit regelmäßigen Backups, Sicherheitsupdates und Performance-Monitoring gesund.
Überprüfen Sie die Werte DB_NAME, DB_USER, DB_PASSWORD und DB_HOST in wp-config.php. Verifizieren Sie, dass MySQL läuft mit 'sudo systemctl status mariadb'. Prüfen Sie, ob der Benutzer Zugriff auf die Datenbank hat mit dem SQL-Befehl 'SHOW GRANTS FOR wpuser@localhost;'.
Prüfen Sie, ob die try_files-Direktive in Ihrer Nginx-Konfiguration korrekt ist. Verifizieren Sie, dass PHP-FPM läuft mit 'sudo systemctl status php8.2-fpm'. Überprüfen Sie das Nginx-Fehlerprotokoll mit 'sudo tail -f /var/log/nginx/mysite.com.error.log'.
Erhöhen Sie upload_max_filesize und post_max_size in php.ini (z.B. 64M). Erhöhen Sie auch client_max_body_size in Nginx auf denselben Wert. Starten Sie PHP-FPM und Nginx neu. Fügen Sie 'define("WP_MAX_MEMORY_LIMIT", "256M");' zu wp-config.php hinzu.
Aktivieren Sie OPcache, verwenden Sie Nginx FastCGI Cache. Installieren Sie W3 Total Cache oder WP Super Cache Plugin. Verwenden Sie ein CDN (Cloudflare). Fügen Sie Smush oder ShortPixel Plugin für Bildoptimierung hinzu. Optimieren Sie die Datenbank regelmäßig mit WP-CLI.
Vollständige Anleitung zum Deployen von Node.js-Anwendungen auf einem VPS. Node.js-Installation mit nvm, PM2 Process Manager, Nginx Reverse Proxy, SSL-Zertifikat und Umgebungsvariablen.
Vollständige Anleitung zum Deployen von PHP-Anwendungen auf einem VPS. LAMP vs LEMP Vergleich, Apache/Nginx + PHP-FPM + MySQL Setup, Virtual Host Konfiguration und PHP-Versionsverwaltung.
Anleitung zum Deployen von Python/Django-Anwendungen auf einem VPS. Virtualenv-Setup, Django-Produktionseinstellungen, Gunicorn WSGI-Server, Nginx Reverse Proxy, systemd-Dienst und statische Dateiverwaltung.