WordPress Production
A production-grade WordPress stack running PHP-FPM behind an Nginx reverse proxy for optimal performance. MariaDB 11.4 serves as the relational database with InnoDB buffer pool tuning, while Redis 7 provides persistent object caching to reduce database load. All services include health checks, resource limits, and named volumes for data durability. The frontend/backend network separation ensures that only Nginx is exposed to external traffic. Ideal for hosting high-traffic WordPress sites in a containerised environment.
Services Inclus
nginx
nginx:1.27-alpine
wordpress
wordpress:6.7-fpm-alpine
Variables d'Environnement :
mariadb
mariadb:11.4
Variables d'Environnement :
redis
redis:7-alpine
YAML Généré
# Generated by ComposeHub (composehub.dev)
name: wordpress-production
services:
nginx:
image: nginx:1.27-alpine
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- nginx_conf:/etc/nginx/conf.d
- wordpress_data:/var/www/html:ro
networks:
- frontend
- backend
depends_on:
wordpress:
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 reverse proxy serving WordPress
wordpress:
image: wordpress:6.7-fpm-alpine
restart: unless-stopped
expose:
- "9000"
volumes:
- wordpress_data:/var/www/html
environment:
WORDPRESS_DB_HOST: mariadb:3306
WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME:-wordpress}
WORDPRESS_DB_USER: ${WORDPRESS_DB_USER:-wordpress}
WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD:-changeme}
WORDPRESS_TABLE_PREFIX: ${WORDPRESS_TABLE_PREFIX:-wp_}
WORDPRESS_CONFIG_EXTRA: define('WP_REDIS_HOST', 'redis'); define('WP_REDIS_PORT', 6379); define('WP_CACHE', true);
networks:
- backend
depends_on:
mariadb:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test:
- CMD-SHELL
- php-fpm-healthcheck || exit 1
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: "1.00"
memory: 512M
reservations:
cpus: "0.25"
memory: 128M
labels:
com.composeforge.description: WordPress PHP-FPM application server
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: ${WORDPRESS_DB_NAME:-wordpress}
MYSQL_USER: ${WORDPRESS_DB_USER:-wordpress}
MYSQL_PASSWORD: ${WORDPRESS_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 relational database
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 object cache for WordPress
networks:
frontend:
driver: bridge
backend:
driver: bridge
volumes:
wordpress_data:
driver: local
mariadb_data:
driver: local
redis_data:
driver: local
nginx_conf:
driver: local
Informations Rapides
- Services
- 4
- Réseaux
- 2
- Volumes
- 4
Quand l'Utiliser
Ce modèle est idéal pour mettre en place un environnement wordpress production Tous les services sont préconfigurés avec des healthchecks, des limites de ressources et des valeurs par défaut raisonnables. Personnalisez les variables d'environnement avant de déployer en production.
Conseils
- Changez tous les mots de passe par défaut avant le déploiement
- Vérifiez les limites de ressources pour votre matériel
- Ajoutez un reverse proxy pour le HTTPS en production
- Configurez des stratégies de sauvegarde pour les volumes de données