Setting Up Matomo Analytics with a Dedicated MariaDB Instance

Overview

This article details the process of deploying Matomo Analytics using a dedicated, isolated MariaDB database. This method ensures that your analytics data remains separate from other services (like Nextcloud), preventing database conflicts and simplifying maintenance.

Prerequisites

1. Docker Compose Configuration

Use the following configuration for a Custom Install in CasaOS:

services:
  matomo_db:
    image: mariadb:10.11
    container_name: matomo_db
    command: --max-allowed-packet=64MB
    environment:
      - MARIADB_ROOT_PASSWORD=matomo_root_password
      - MARIADB_DATABASE=matomo
      - MARIADB_USER=matomo
      - MARIADB_PASSWORD=matomo_secure
    volumes:
      - /DATA/AppData/matomo/db:/var/lib/mysql
    restart: unless-stopped

  matomo_app:
    image: matomo:latest
    container_name: matomo_app
    restart: unless-stopped
    ports:
      - "8484:80"
    environment:
      - MATOMO_DATABASE_HOST=matomo_db
      - MATOMO_DATABASE_DBNAME=matomo
      - MATOMO_DATABASE_USERNAME=matomo
      - MATOMO_DATABASE_PASSWORD=matomo_secure
    volumes:
      - /DATA/AppData/matomo/html:/var/www/html
    depends_on:
      - matomo_db

2. Database Connection Credentials

During the Matomo web-based setup wizard, use these internal credentials:

Setting Value
Database Server matomo_db
Login matomo
Password matomo_secure
Database Name matomo

3. Implementation on BookStack

  1. Log in to Matomo and navigate to Administration > Websites > Manage.
  2. Copy the JavaScript Tracking Code.
  3. In BookStack, navigate to Settings > Customization.
  4. Paste the script into the Custom HTML Head Content area and save.

Revision #1
Created 2026-03-29 21:20:00 UTC by Francis
Updated 2026-03-29 21:20:39 UTC by Francis