LEMP Stack
A classic LEMP (Linux, Nginx, MariaDB, PHP) stack extended with Redis caching and Adminer for convenient database administration. Nginx 1.27 serves static files directly and forwards PHP requests to the PHP-FPM 8.3 container via FastCGI, with shared volumes ensuring both services see the same application code. MariaDB 11.4 provides the relational database layer with tuned InnoDB settings, while Redis 7 handles session storage and application caching. Adminer offers a lightweight, single-file web UI for database management on a dedicated port. All database services include health checks and the network is split between frontend (public) and backend (internal) tiers.
Enthaltene Services
nginx
nginx:1.27-alpine
php
php:8.3-fpm-alpine
Umgebungsvariablen:
mariadb
mariadb:11.4
Umgebungsvariablen:
redis
redis:7-alpine
adminer
adminer:4-standalone
Umgebungsvariablen:
Generiertes YAML
# Generated by ComposeHub (composehub.dev)
name: lemp-stack
services:
nginx:
image: nginx:1.27-alpine
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- nginx_conf:/etc/nginx/conf.d
- app_data:/var/www/html:ro
networks:
- frontend
- backend
depends_on:
php:
condition: service_healthy
healthcheck:
test:
- CMD
- curl
- "-f"
- http://localhost
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: "0.50"
memory: 256M
reservations:
cpus: "0.10"
memory: 64M
labels:
com.composeforge.description: Nginx web server with FastCGI proxy to PHP-FPM
php:
image: php:8.3-fpm-alpine
restart: unless-stopped
expose:
- "9000"
volumes:
- app_data:/var/www/html
environment:
PHP_MEMORY_LIMIT: ${PHP_MEMORY_LIMIT:-256M}
PHP_MAX_EXECUTION_TIME: ${PHP_MAX_EXECUTION_TIME:-60}
PHP_UPLOAD_MAX_FILESIZE: ${PHP_UPLOAD_MAX_FILESIZE:-64M}
PHP_POST_MAX_SIZE: ${PHP_POST_MAX_SIZE:-64M}
networks:
- backend
depends_on:
mariadb:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test:
- CMD-SHELL
- php-fpm-healthcheck || kill -0 1
interval: 30s
timeout: 10s
retries: 5
start_period: 20s
deploy:
resources:
limits:
cpus: "1.00"
memory: 512M
reservations:
cpus: "0.25"
memory: 128M
labels:
com.composeforge.description: PHP-FPM 8.3 application server
mariadb:
image: mariadb:11.4
restart: unless-stopped
command:
- "--innodb-buffer-pool-size=256M"
- "--innodb-log-file-size=64M"
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_unicode_ci"
volumes:
- mariadb_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-rootchangeme}
MYSQL_DATABASE: ${MYSQL_DATABASE:-app}
MYSQL_USER: ${MYSQL_USER:-app}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-changeme}
networks:
- backend
healthcheck:
test:
- CMD
- healthcheck.sh
- "--connect"
- "--innodb_initialized"
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
deploy:
resources:
limits:
cpus: "1.00"
memory: 512M
reservations:
cpus: "0.25"
memory: 256M
labels:
com.composeforge.description: MariaDB 11.4 relational database
redis:
image: redis:7-alpine
restart: unless-stopped
command:
- redis-server
- "--maxmemory"
- 64mb
- "--maxmemory-policy"
- allkeys-lru
- "--appendonly"
- yes
- "--appendfsync"
- everysec
volumes:
- redis_data:/data
networks:
- backend
healthcheck:
test:
- CMD
- redis-cli
- ping
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: "0.50"
memory: 128M
reservations:
cpus: "0.10"
memory: 32M
labels:
com.composeforge.description: Redis 7 in-memory cache and session store
adminer:
image: adminer:4-standalone
restart: unless-stopped
ports:
- 8080:8080
environment:
ADMINER_DEFAULT_SERVER: mariadb
ADMINER_DESIGN: ${ADMINER_DESIGN:-pepa-linha-dark}
networks:
- frontend
- backend
depends_on:
mariadb:
condition: service_healthy
healthcheck:
test:
- CMD-SHELL
- curl -f http://localhost:8080 || exit 1
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: "0.25"
memory: 128M
reservations:
cpus: "0.05"
memory: 32M
labels:
com.composeforge.description: Adminer web-based database management UI
networks:
frontend:
driver: bridge
backend:
driver: bridge
volumes:
app_data:
driver: local
mariadb_data:
driver: local
redis_data:
driver: local
nginx_conf:
driver: local
Kurzinfo
- Services
- 5
- Netzwerke
- 2
- Volumes
- 4
Wann verwenden
Dieses Template ist ideal für die Einrichtung einer lemp stack Umgebung. Alle Services sind mit Healthchecks, Ressourcenlimits und sinnvollen Standardwerten vorkonfiguriert. Passen Sie die Umgebungsvariablen an, bevor Sie in Produktion gehen.
Tipps
- Ändern Sie alle Standardpasswörter vor dem Deployment
- Überprüfen Sie die Ressourcenlimits für Ihre Hardware
- Fügen Sie einen Reverse Proxy für HTTPS in Produktion hinzu
- Konfigurieren Sie Backup-Strategien für Daten-Volumes