# WooCommerce E-commerce Stack

> WordPress WooCommerce with MySQL and Redis.

- Category: E-Commerce & Business
- Difficulty: intermediate
- Components: wordpress, mysql, redis, nginx
- Tags: woocommerce, wordpress, ecommerce, shop
- Source: https://docker.recipes/ecommerce/woocommerce-stack

## Overview

WordPress powers over 40% of websites globally, serving as the world's most popular content management system with an ecosystem of 60,000+ plugins and thousands of themes. WooCommerce extends WordPress into a full-featured e-commerce platform, handling everything from product catalogs and inventory management to payment processing and order fulfillment. This stack combines WordPress and WooCommerce with MySQL for reliable data storage, Redis for high-performance caching and session management, and Nginx as a reverse proxy to handle HTTP requests efficiently. MySQL provides ACID-compliant transactions essential for e-commerce operations, while Redis delivers sub-millisecond response times for cart data and user sessions. Nginx's event-driven architecture serves static assets like product images while proxying dynamic requests to WordPress, creating a robust foundation for online stores. This combination is ideal for e-commerce businesses seeking a proven, scalable platform with extensive customization options. Startups can leverage WooCommerce's free core with premium extensions as they grow, while established retailers benefit from the vast ecosystem of themes, payment gateways, and marketing tools. The stack supports everything from digital downloads to complex physical product catalogs with variations, making it suitable for businesses ranging from artisan shops to enterprise retailers processing thousands of orders daily.

## Features

- WooCommerce plugin ecosystem with 400+ official extensions for payments, shipping, and marketing
- WordPress Gutenberg block editor with WooCommerce product blocks for visual store building
- MySQL InnoDB storage engine with ACID compliance for transaction integrity
- Redis object caching for WordPress database queries and WooCommerce cart persistence
- Nginx FastCGI caching with WordPress-specific rules for dynamic content optimization
- WordPress REST API and WooCommerce API for headless commerce implementations
- MySQL full-text search capabilities for product catalog indexing
- Redis session storage for improved checkout performance and user experience

## Use cases

- Small to medium online retailers selling physical products with inventory management
- Digital product marketplaces offering downloads, courses, or subscription services
- Multi-vendor marketplaces using WooCommerce marketplace extensions
- B2B wholesale stores with tiered pricing and customer-specific catalogs
- Dropshipping businesses integrating with suppliers and fulfillment services
- Subscription-based businesses selling recurring products or memberships
- Local businesses expanding online with pickup/delivery options and local payment methods

## Prerequisites

- Minimum 2GB RAM (MySQL 1GB, WordPress 512MB, Redis 256MB, Nginx 256MB)
- Available ports 80 and 443 for HTTP/HTTPS traffic
- Understanding of WordPress administration and plugin management
- Basic knowledge of WooCommerce store configuration and product setup
- SSL certificate for secure payment processing (Let's Encrypt recommended)
- Familiarity with payment gateway APIs (Stripe, PayPal, etc.) for transaction processing

## docker-compose.yml

```yaml
services:
  wordpress:
    image: wordpress:latest
    container_name: woocommerce
    restart: unless-stopped
    environment:
      - WORDPRESS_DB_HOST=woo-mysql
      - WORDPRESS_DB_USER=${DB_USER}
      - WORDPRESS_DB_PASSWORD=${DB_PASSWORD}
      - WORDPRESS_DB_NAME=woocommerce
    volumes:
      - wordpress_data:/var/www/html
    depends_on:
      - woo-mysql
      - woo-redis

  woo-mysql:
    image: mysql:8.0
    container_name: woo-mysql
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
      - MYSQL_DATABASE=woocommerce
      - MYSQL_USER=${DB_USER}
      - MYSQL_PASSWORD=${DB_PASSWORD}
    volumes:
      - mysql_data:/var/lib/mysql

  woo-redis:
    image: redis:7-alpine
    container_name: woo-redis
    restart: unless-stopped
    volumes:
      - redis_data:/data

  nginx:
    image: nginx:alpine
    container_name: woo-nginx
    restart: unless-stopped
    ports:
      - "${NGINX_PORT:-80}:80"
      - "${NGINX_SSL_PORT:-443}:443"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - wordpress_data:/var/www/html:ro
    depends_on:
      - wordpress

volumes:
  wordpress_data:
  mysql_data:
  redis_data:
```

## .env

```bash
# WooCommerce
NGINX_PORT=80
NGINX_SSL_PORT=443
DB_USER=woocommerce
DB_PASSWORD=woo_password
DB_ROOT_PASSWORD=root_password
```

## Usage notes

- Docs: https://woocommerce.com/documentation/
- WooCommerce at http://localhost through Nginx reverse proxy
- Complete WordPress setup wizard, then install WooCommerce plugin
- Redis Object Cache plugin for performance (connect to woo-redis:6379)
- Configure payment gateways: Stripe, PayPal, bank transfer
- SSL recommended - use Let's Encrypt with certbot

## Troubleshooting

- WordPress database connection error: Verify WORDPRESS_DB_HOST points to 'woo-mysql' and database credentials match MYSQL_USER/MYSQL_PASSWORD
- WooCommerce checkout timeouts: Install Redis Object Cache plugin and configure it to connect to 'woo-redis:6379' for session persistence
- MySQL max_connections exceeded: Add 'max_connections=200' to MySQL environment variables or custom configuration file
- Nginx 502 Bad Gateway errors: Check that WordPress container is healthy and PHP-FPM is responding on port 9000
- WooCommerce product images not loading: Ensure wordpress_data volume is mounted to both WordPress and Nginx containers with proper permissions
- Redis memory usage warnings: Configure Redis maxmemory policy with 'maxmemory-policy allkeys-lru' for cache eviction

