# WordPress Bedrock Professional

> Modern WordPress stack with Bedrock, Composer, Redis object cache, and security hardening.

- Category: CMS & Blogging
- Difficulty: intermediate
- Components: php-fpm, nginx, mariadb, redis, mailhog
- Tags: wordpress, bedrock, composer, professional, security
- Source: https://docker.recipes/cms/wordpress-bedrock

## Overview

PHP-FPM (FastCGI Process Manager) is a scalable PHP processor that handles web requests through a pool of worker processes, offering superior performance and resource management compared to traditional mod_php implementations. This professional WordPress stack combines PHP-FPM with NGINX for high-performance web serving, while Bedrock modernizes WordPress development through Composer dependency management, environment-specific configurations, and enhanced security practices that separate WordPress core files from custom application code.

The integration of MariaDB provides robust database performance with enhanced storage engines and clustering capabilities, while Redis delivers sub-millisecond object caching that dramatically reduces database queries and improves page load times. NGINX handles SSL termination, static file serving, and request routing with its event-driven architecture, while MailHog captures outgoing emails during development to prevent accidental sends to real users.

This configuration serves development teams, digital agencies, and WordPress professionals who require modern development workflows, enhanced security postures, and enterprise-grade performance. The Bedrock framework's structured approach to WordPress development, combined with Redis object caching and MariaDB's advanced features, creates a foundation suitable for high-traffic WordPress sites that demand both developer productivity and operational reliability.

## Features

- Bedrock framework with Composer-managed WordPress core and plugin dependencies
- PHP-FPM process pool management with configurable worker processes and memory limits
- Redis object cache integration reducing database queries by 80-95% on cached content
- MariaDB 11 with Aria storage engine and thread pool connection handling
- NGINX FastCGI caching with configurable cache zones and purging capabilities
- Environment-specific configuration through .env files separating development and production settings
- MailHog email interception preventing accidental email sends during development
- Structured WordPress installation with web root separation and enhanced security headers

## Use cases

- WordPress agencies managing multiple client sites with consistent deployment workflows
- High-traffic WordPress sites requiring object caching and database optimization
- Development teams needing modern PHP dependency management and version control
- WordPress multisite networks with centralized plugin and theme management
- E-commerce WordPress sites with WooCommerce requiring enhanced performance
- Enterprise WordPress deployments with strict security and compliance requirements
- WordPress development environments with email testing and debugging capabilities

## Prerequisites

- Docker Engine 20.10+ and Docker Compose V2 for container orchestration
- Minimum 2GB RAM (4GB recommended) for MariaDB, Redis, and PHP-FPM processes
- Composer knowledge for managing Bedrock dependencies and WordPress plugins
- Basic understanding of WordPress file structure and wp-config.php alternatives
- Familiarity with environment variables and .env file configuration
- Available ports 80, 443, 1025, and 8025 for web and mail services

## docker-compose.yml

```yaml
services:
  nginx:
    image: nginx:alpine
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - ./certs:/etc/nginx/certs:ro
      - wordpress_data:/var/www/html
    depends_on:
      - php
    networks:
      - wp-net
    restart: unless-stopped

  php:
    build:
      context: .
      dockerfile: Dockerfile.php
    volumes:
      - wordpress_data:/var/www/html
      - ./php.ini:/usr/local/etc/php/conf.d/custom.ini:ro
    environment:
      DB_HOST: mariadb
      DB_NAME: ${MYSQL_DATABASE}
      DB_USER: ${MYSQL_USER}
      DB_PASSWORD: ${MYSQL_PASSWORD}
      WP_ENV: development
      WP_HOME: http://localhost
      WP_SITEURL: http://localhost/wp
      REDIS_HOST: redis
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_started
    networks:
      - wp-net
    restart: unless-stopped

  mariadb:
    image: mariadb:11
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    volumes:
      - mariadb_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - wp-net
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    volumes:
      - redis_data:/data
    networks:
      - wp-net
    restart: unless-stopped

  mailhog:
    image: mailhog/mailhog:latest
    ports:
      - "1025:1025"
      - "8025:8025"
    networks:
      - wp-net
    restart: unless-stopped

volumes:
  wordpress_data:
  mariadb_data:
  redis_data:

networks:
  wp-net:
    driver: bridge
```

## .env

```bash
# Database Configuration
MYSQL_ROOT_PASSWORD=secure_root_password
MYSQL_DATABASE=wordpress
MYSQL_USER=wordpress
MYSQL_PASSWORD=secure_mysql_password

# WordPress Salts (generate at https://roots.io/salts.html)
AUTH_KEY=
SECURE_AUTH_KEY=
LOGGED_IN_KEY=
NONCE_KEY=
AUTH_SALT=
SECURE_AUTH_SALT=
LOGGED_IN_SALT=
NONCE_SALT=
```

## Usage notes

- Create Dockerfile.php with Bedrock dependencies
- Install Bedrock: composer create-project roots/bedrock
- MailHog for email testing at http://localhost:8025
- Redis Object Cache plugin recommended

## Troubleshooting

- PHP-FPM 'pool seems busy' errors: Increase pm.max_children and pm.max_requests in php-fpm pool configuration
- Bedrock 'vendor directory not found' error: Run 'composer install' in the WordPress root directory before starting containers
- Redis connection refused from PHP: Verify Redis service is running and REDIS_HOST environment variable matches service name
- MariaDB 'Access denied for user' errors: Check MYSQL_USER and MYSQL_PASSWORD environment variables match between PHP and MariaDB services
- NGINX 502 Bad Gateway errors: Ensure PHP-FPM container is healthy and FastCGI pass configuration points to correct upstream
- MailHog not capturing emails: Verify PHP mail configuration uses mailhog:1025 as SMTP server in php.ini

