来源
正文
公众号名称:出发了很久别忘记出发的目的
作者名称:
发布时间:2026-04-14 21:09
1、demo
详见:https://demo.matomo.cloud

2、安装要求
详见:
https://github.com/matomo-org/matomo
https://matomo.org/faq/on-premise/matomo-requirements



3、安装 Docker
4、安装 Matomo
详见;
https://github.com/matomo-org/matomo
https://matomo.org/faq/on-premise/matomo-requirements
https://matomo.org/faq/on-premise/installing-matomo
https://github.com/matomo-org/docker
4.1、方式 1
创建目录:
mkdir matomo
切换目录:
cd matomo
创建 docker-compose.yaml 文件:
services:
mysql:
image: mysql:latest
container_name: matomo-mysql
restart: always
volumes:
- ./mysql/data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=matomo
php:
image: matomo:latest
container_name: matomo
restart: always
ports:
- 8080:80
volumes:
- ./matomo:/var/www/html
depends_on:
- mysql
links:
- mysql
创建并启动容器:
docker-compose up -d
查看容器列表:
docker ps
停止并销毁容器:
docker-compose down
删除目录:
rm -rf ./matomo ./mysql
删除镜像:
docker rmi matomo:latest mysql:latest
4.2、方式 2
创建目录:
mkdir -p matomo/nginx/conf.d
切换目录:
cd matomo
下载:
# 方式1:
wget https://github.com/matomo-org/matomo/releases/download/5.8.0/matomo-5.8.0.tar.gz
# 方式2:
# 详见:https://mp.weixin.qq.com/s/XTbT3wKp_W2fiK7pGpo7Qg
wget https://gh-proxy.com/https://github.com/matomo-org/matomo/releases/download/5.8.0/matomo-5.8.0.tar.gz
解压:
tar -xf matomo-5.8.0.tar.gz
添加权限:
chmod -Rf 777 matomo
创建 Dockerfile 文件:
FROM php:8-fpm
RUN docker-php-ext-install mysqli pdo_mysql
构建镜像:
docker build -t php8:v1 .
创建 nginx/conf.d/default.conf 文件:
server {
listen 80;
listen [::]:80;
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
location / {
#root /usr/share/nginx/html;
#index index.html index.htm;
root /usr/share/nginx/html/matomo;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /var/www/html/matomo;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
创建 docker-compose.yaml 文件:
services:
mysql:
image: mysql:latest
container_name: matomo-mysql
restart: always
volumes:
- ./mysql/data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
php:
#image: php:8-fpm
image: php8:v1
container_name: matomo-php
restart: always
volumes:
- ./matomo:/var/www/html/matomo
depends_on:
- mysql
links:
- mysql
nginx:
image: nginx:latest
container_name: matomo-nginx
restart: always
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
- ./matomo:/usr/share/nginx/html/matomo
ports:
- 8080:80
depends_on:
- php
links:
- php
创建并启动容器:
docker-compose up -d
查看容器列表:
docker ps
停止并销毁容器:
docker-compose down
删除目录:
rm -rf ./mysql
删除镜像:
docker rmi nginx:latest php8:v1 mysql:latest
删除所有未使用的构建缓存:
docker builder prune
5、浏览器访问
详见:https://matomo.org/faq/on-premise/installing-matomo/
假设当前ip为192.168.186.128
浏览器访问:http://192.168.186.128:8080
欢迎:

系统检查:

数据库设置:
数据库服务器:mysql
数据库账号:root
密码:root
数据库名称:matomo

建立数据表中:

超级用户:

建立网站:

JavaScript 跟踪代码:

恭喜:

登录:

后台:

"使用 Matomo 标签管理器 安装 Matomo(推荐给您)"

"安装 Matomo 的其他方法"






管理:

6、详见
https://matomo.org
https://github.com/matomo-org/matomo
https://github.com/matomo-org/docker
https://www.browserstack.com
内容效果不满意?点此反馈

.png)
-bpoi.png)
