Run Matomo - Google Analytics Alternative - in Docker 🌱

What is Matomo?

Matomo is the leading Free/Libre open analytics platform. Matomo aims to be a Free software alternative to Google Analytics and is already used on more than 1,400,000 websites. Privacy is built-in! -https://github.com/matomo-org/matomo

Installing Docker

  1. Log into the Linux based device
  2. Run the following commands in the terminal
    # install prerequisites
    sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
    # add docker gpg key
    curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
    # add docker software repository
    sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
    # install docker
    sudo apt install docker-ce docker-compose containerd.io -y
    # enable and start docker service
    sudo systemctl enable docker && sudo systemctl start docker
    # add the current user to the docker group
    sudo usermod -aG docker $USER
    # reauthenticate for the new group membership to take effect
    su - $USER

Running Matomo

  1. Continue with the following commands in a terminal window
    # create a working directory
    mkdir ~/docker/matomo -p && mkdir ~/docker/mariadb -p
    # set owner of working directories
    sudo chown "$USER":"$USER" ~/docker -R
    # allow the container to write to working directories
    sudo chmod a+rwx -R ~/docker/matomo
    # run the mariadb docker container
    docker run -d --name mariadb -e MYSQL_ROOT_PASSWORD=r00tp@$$ -e MYSQL_USER=matomo_rw -e MYSQL_PASSWORD='M4tom0!' -e MYSQL_DATABASE=matomo -v ~/docker/mariadb:/var/lib/mysql -p 3306:3006 --restart=unless-stopped mariadb:latest
    # start the matomo container
    docker run -d --name matomo --link mariadb -p 80:80 -v ~/docker/matomo:/var/www/html -e MATOMO_DATABASE_HOST=mariadb -e MATOMO_DATABASE_USERNAME=matomo_rw -e MATOMO_DATABASE_PASSWORD='M4tom0!' -e MATOMO_DATABASE_DBNAME=matomo --restart=unless-stopped matomo
  2. Open a web browser and navigate to http://DNSorIP
  3. Click Next at the Welcome screen
  4. Scroll to the bottom of the System Check screen > Click Next
  5. Verify the Database Setup form > Click Next
  6. Click Next on the Creating the Tables page
  7. Enter a Superuser login, password and email > Click Next
  8. Complete the form to setup the first site to start tracking analytics > Click Next
  9. Click Next then Continue to Matomo
  10. Login with the Superuser username and password created earlier
  11. Welcome to Matomo

Additional Information: https://matomo.org/