Laravel Stack
A complete Laravel development and production stack built around PHP-FPM 8.3 and Nginx. MariaDB 11.4 serves as the primary database with InnoDB tuning, while Redis 7 handles cache, sessions, and queue storage for Laravel Horizon or the built-in queue worker. Mailhog intercepts all outgoing SMTP traffic on port 1025 and provides a web UI on port 8025 so developers can inspect emails without hitting real inboxes. Nginx routes all requests through PHP-FPM with proper try_files and fastcgi_pass configuration. The stack uses isolated frontend and backend networks, named volumes for code and data, and resource limits on every service.
Enthaltene Services
nginx
nginx:1.27-alpine
php
php:8.3-fpm-alpine
Umgebungsvariablen:
mariadb
mariadb:11.4
Umgebungsvariablen:
redis
redis:7-alpine
mailhog
mailhog/mailhog:latest
Umgebungsvariablen:
Generiertes YAML
# Generated by ComposeHub (composehub.dev)
name: laravel-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 proxying to PHP-FPM for Laravel
php:
image: php:8.3-fpm-alpine
restart: unless-stopped
expose:
- "9000"
volumes:
- app_data:/var/www/html
environment:
APP_NAME: ${APP_NAME:-Laravel}
APP_ENV: ${APP_ENV:-production}
APP_KEY: ${APP_KEY:-base64:GENERATE_A_NEW_KEY}
APP_DEBUG: ${APP_DEBUG:-false}
APP_URL: ${APP_URL:-http://localhost}
LOG_CHANNEL: ${LOG_CHANNEL:-stderr}
DB_CONNECTION: mysql
DB_HOST: mariadb
DB_PORT: "3306"
DB_DATABASE: ${DB_DATABASE:-laravel}
DB_USERNAME: ${DB_USERNAME:-laravel}
DB_PASSWORD: ${DB_PASSWORD:-changeme}
CACHE_DRIVER: redis
SESSION_DRIVER: redis
QUEUE_CONNECTION: redis
REDIS_HOST: redis
REDIS_PORT: "6379"
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
MAIL_MAILER: smtp
MAIL_HOST: mailhog
MAIL_PORT: "1025"
MAIL_FROM_ADDRESS: ${MAIL_FROM_ADDRESS:[email protected]}
MAIL_FROM_NAME: ${APP_NAME:-Laravel}
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 running the Laravel application
mariadb:
image: mariadb:11.4
restart: unless-stopped
command:
- "--innodb-buffer-pool-size=256M"
- "--innodb-log-file-size=64M"
- "--innodb-flush-method=O_DIRECT"
- "--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: ${DB_DATABASE:-laravel}
MYSQL_USER: ${DB_USERNAME:-laravel}
MYSQL_PASSWORD: ${DB_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 database for Laravel
redis:
image: redis:7-alpine
restart: unless-stopped
command:
- redis-server
- "--maxmemory"
- 128mb
- "--maxmemory-policy"
- allkeys-lru
- "--appendonly"
- yes
- "--appendfsync"
- everysec
- "--save"
- "60"
- "1000"
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: 192M
reservations:
cpus: "0.10"
memory: 64M
labels:
com.composeforge.description: Redis 7 for cache, sessions, and queues
mailhog:
image: mailhog/mailhog:latest
restart: unless-stopped
ports:
- 8025:8025
expose:
- "1025"
environment:
MH_STORAGE: memory
MH_UI_WEB_PATH: ${MH_UI_WEB_PATH:-}
networks:
- backend
healthcheck:
test:
- CMD-SHELL
- wget --no-verbose --tries=1 --spider http://localhost:8025 || 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: Mailhog SMTP testing server with web 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 laravel 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