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.
शामिल सर्विसेज़
nginx
nginx:1.27-alpine
php
php:8.3-fpm-alpine
एनवायरनमेंट वेरिएबल्स:
mariadb
mariadb:11.4
एनवायरनमेंट वेरिएबल्स:
redis
redis:7-alpine
adminer
adminer:4-standalone
एनवायरनमेंट वेरिएबल्स:
जनरेटेड 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
त्वरित जानकारी
- सर्विसेज़
- 5
- नेटवर्क्स
- 2
- वॉल्यूम्स
- 4
कब उपयोग करें
यह टेम्पलेट एक lemp stack एनवायरनमेंट सेटअप के लिए आदर्श है। सभी सर्विसेज़ healthchecks, रिसोर्स लिमिट्स और उचित डिफ़ॉल्ट सेटिंग्स के साथ पहले से कॉन्फ़िगर्ड हैं। प्रोडक्शन में डिप्लॉय करने से पहले एनवायरनमेंट वेरिएबल्स कस्टमाइज़ करें।
सुझाव
- डिप्लॉय करने से पहले सभी डिफ़ॉल्ट पासवर्ड बदलें
- अपने हार्डवेयर के अनुसार रिसोर्स लिमिट्स की समीक्षा करें
- प्रोडक्शन HTTPS के लिए रिवर्स प्रॉक्सी जोड़ें
- डेटा वॉल्यूम्स के लिए बैकअप रणनीतियाँ कॉन्फ़िगर करें