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