LEMP Stack auf Ubuntu installieren | Enjyn Gruppe
Hallo Welt
Hallo Welt
Original Lingva Deutsch
Übersetzung wird vorbereitet...
Dieser Vorgang kann bis zu 60 Sekunden dauern.
Diese Seite wird erstmalig übersetzt und dann für alle Besucher gespeichert.
0%
DE Zurück zu Deutsch
Übersetzung durch Lingva Translate

241 Dokumentationen verfügbar

Wissensdatenbank

LEMP Stack Ubuntu Installation

Zuletzt aktualisiert: 11.01.2026 um 11:53 Uhr

LEMP Stack auf Ubuntu installieren

Der LEMP Stack ersetzt Apache durch Nginx - einen schnelleren, ressourcenschonenderen Webserver. Ideal für moderne Webanwendungen, WordPress und High-Traffic-Websites.

LAMP vs. LEMP

Aspekt LAMP (Apache) LEMP (Nginx)
Performance Gut Sehr gut (weniger RAM)
Konfiguration .htaccess möglich Nur Server-Config
Statische Dateien Gut Exzellent
Reverse Proxy Möglich Native Stärke

1. System aktualisieren

sudo apt update && sudo apt upgrade -y

2. Nginx installieren

# Nginx installieren
sudo apt install nginx -y

# Status prüfen
sudo systemctl status nginx

# Autostart aktivieren
sudo systemctl enable nginx

# Firewall
sudo ufw allow 'Nginx Full'

Test: http://IHRE-SERVER-IP zeigt Nginx-Willkommensseite.

3. MySQL/MariaDB installieren

# MariaDB installieren (empfohlen)
sudo apt install mariadb-server -y

# Absichern
sudo mysql_secure_installation

Datenbank einrichten

sudo mysql

CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'sicheres_passwort';
CREATE DATABASE meine_webapp;
GRANT ALL PRIVILEGES ON meine_webapp.* TO 'webuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

4. PHP-FPM installieren

Nginx nutzt PHP-FPM (FastCGI Process Manager) statt mod_php:

# PHP-FPM mit Modulen
sudo apt install php-fpm php-mysql php-cli php-curl php-gd php-mbstring php-xml php-zip php-intl php-bcmath -y

# PHP-Version prüfen
php -v

# PHP-FPM Status
sudo systemctl status php8.3-fpm

5. Nginx für PHP konfigurieren

Standard-Konfiguration anpassen

sudo nano /etc/nginx/sites-available/default
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.php index.html index.htm;

    server_name _;

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

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

    # .htaccess blockieren
    location ~ /\.ht {
        deny all;
    }
}
# Konfiguration testen
sudo nginx -t

# Nginx neu laden
sudo systemctl reload nginx

6. PHP testen

sudo nano /var/www/html/info.php
<?php
phpinfo();
?>

Öffnen: http://IHRE-SERVER-IP/info.php

# Nach Test löschen!
sudo rm /var/www/html/info.php

7. Virtual Host (Server Block) einrichten

# Verzeichnis erstellen
sudo mkdir -p /var/www/meine-website.de/public_html
sudo chown -R $USER:$USER /var/www/meine-website.de

# Server Block erstellen
sudo nano /etc/nginx/sites-available/meine-website.de
server {
    listen 80;
    listen [::]:80;
    
    server_name meine-website.de www.meine-website.de;
    root /var/www/meine-website.de/public_html;
    
    index index.php index.html;
    
    # Logging
    access_log /var/log/nginx/meine-website.de.access.log;
    error_log /var/log/nginx/meine-website.de.error.log;
    
    # Hauptlocation
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    # PHP
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
    
    # Statische Dateien cachen
    location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg|woff|woff2)$ {
        expires 30d;
        add_header Cache-Control "public, immutable";
    }
    
    # Versteckte Dateien blockieren
    location ~ /\. {
        deny all;
    }
}
# Site aktivieren
sudo ln -s /etc/nginx/sites-available/meine-website.de /etc/nginx/sites-enabled/

# Testen und neu laden
sudo nginx -t
sudo systemctl reload nginx

8. PHP-FPM optimieren

sudo nano /etc/php/8.3/fpm/php.ini
# Anpassungen
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 256M
max_execution_time = 300
date.timezone = Europe/Berlin

Pool-Konfiguration

sudo nano /etc/php/8.3/fpm/pool.d/www.conf
# Für Server mit 4GB RAM:
pm = dynamic
pm.max_children = 20
pm.start_servers = 5
pm.min_spare_servers = 3
pm.max_spare_servers = 10
sudo systemctl restart php8.3-fpm

WordPress mit LEMP

server {
    listen 80;
    server_name wordpress.example.com;
    root /var/www/wordpress;
    index index.php;
    
    # WordPress Permalinks
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    
    # PHP
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
    }
    
    # wp-config.php schützen
    location = /wp-config.php {
        deny all;
    }
    
    # xmlrpc.php blockieren
    location = /xmlrpc.php {
        deny all;
    }
}

Nützliche Nginx-Befehle

sudo nginx -t              # Konfiguration testen
sudo systemctl reload nginx # Ohne Neustart neu laden
sudo systemctl restart nginx
sudo tail -f /var/log/nginx/error.log

Weitere Hilfe

Enjix Beta

Enjyn AI Agent

Hallo 👋 Ich bin Enjix — wie kann ich dir helfen?
120