差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
| 软件:matomo [2025/10/06 03:31] – admin | 软件:matomo [2025/10/06 23:02] (当前版本) – admin | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | Matomo是一个开源的网站分析平台 | + | Matomo是一个开源的网站页面流量统计与分析平台 |
| - | [[https://builds.matomo.org]] | + | [[https:// |
| - | 下载 | + | 下载,将 zip 文件解压缩到硬盘驱动器上的文件夹中。这将创建一个包含文件和目录的“matomo”文件夹。 |
| <code -> | <code -> | ||
| 行 41: | 行 41: | ||
| 服务器配置 | 服务器配置 | ||
| - | < | + | < |
| server { | server { | ||
| - | listen [::]:80; # remove this if you don't want Matomo to be reachable from IPv6 | + | listen [::]:4433 ssl http2; # remove this if you don't want Matomo to be reachable from IPv6 |
| - | listen 80; | + | listen |
| - | server_name matomo.example.com; | + | server_name matomo.localhost; # list all domains Matomo should be reachable from |
| - | # Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response. | + | |
| - | location / { | + | |
| - | return 301 https:// | + | |
| - | } | + | |
| - | } | + | |
| - | server { | + | |
| - | listen [:: | + | |
| - | listen | + | |
| - | server_name matomo.example.com; # list all domains Matomo should be reachable from | + | |
| access_log / | access_log / | ||
| error_log / | error_log / | ||
| 行 63: | 行 54: | ||
| ## replace with your SSL certificate | ## replace with your SSL certificate | ||
| - | ssl_certificate /etc/letsencrypt/live/matomo.example.com/fullchain.pem; | + | ssl_certificate |
| - | ssl_certificate_key /etc/letsencrypt/live/ | + | ssl_certificate_key /etc/nginx/conf.d/cert/ |
| - | include ssl.conf; # if you want to support older browsers, please read through this file | + | |
| + | # ssl_session_timeout 1d; | ||
| + | # ssl_session_cache shared: | ||
| + | # ssl_session_tickets off; | ||
| + | # modern configuration. tweak to your needs. | ||
| + | # ssl_protocols TLSv1.2; | ||
| + | # ssl_ciphers ' | ||
| + | # ssl_prefer_server_ciphers on; | ||
| + | # OCSP Stapling --- | ||
| + | # fetch OCSP records from URL in ssl_certificate and cache them | ||
| + | ssl_stapling on; | ||
| + | ssl_stapling_verify on; | ||
| add_header Referrer-Policy origin always; # make sure outgoing links don't show the URL to the Matomo instance | add_header Referrer-Policy origin always; # make sure outgoing links don't show the URL to the Matomo instance | ||
| 行 81: | 行 83: | ||
| try_files $fastcgi_script_name =404; # protects against CVE-2019-11043. If this line is already included in your snippets/ | try_files $fastcgi_script_name =404; # protects against CVE-2019-11043. If this line is already included in your snippets/ | ||
| fastcgi_param HTTP_PROXY ""; | fastcgi_param HTTP_PROXY ""; | ||
| - | fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; | + | fastcgi_pass unix:/ |
| # | # | ||
| } | } | ||
| 行 133: | 行 135: | ||
| # vim: filetype=nginx | # vim: filetype=nginx | ||
| </ | </ | ||
| + | |||
| + | 添加Nginx规则 | ||
| <code -> | <code -> | ||
| - | Nginx | ||
| cd / | cd / | ||
| - | server { | + | #粘贴Nginx配置matomo.conf |
| - | listen [:: | + | |
| - | listen 80; | + | |
| - | server_name | + | |
| - | # Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response. | + | |
| - | location / { | + | |
| - | return 301 https:// | + | |
| - | } | + | |
| - | } | + | |
| - | server { | + | |
| - | listen [::]:443 ssl http2; # remove this if you don't want Matomo to be reachable from IPv6 | + | |
| - | listen 443 ssl http2; | + | |
| - | server_name matomo.example.com; | + | |
| - | access_log / | + | |
| - | error_log / | + | |
| - | + | ||
| - | ## uncomment if you want to enable HSTS with 6 months cache | + | |
| - | ## ATTENTION: Be sure you know the implications of this change (you won't be able to disable HTTPS anymore) | + | |
| - | #add_header Strict-Transport-Security max-age=15768000 always; | + | |
| - | + | ||
| - | ## replace with your SSL certificate | + | |
| - | ssl_certificate / | + | |
| - | ssl_certificate_key / | + | |
| - | + | ||
| - | include ssl.conf; # if you want to support older browsers, please read through this file | + | |
| - | + | ||
| - | add_header Referrer-Policy origin always; # make sure outgoing links don't show the URL to the Matomo instance | + | |
| - | add_header X-Content-Type-Options " | + | |
| - | add_header X-XSS-Protection "1; mode=block" | + | |
| - | + | ||
| - | root / | + | |
| - | + | ||
| - | index index.php; | + | |
| - | + | ||
| - | ## only allow accessing the following php files | + | |
| - | location ~ ^/ | + | |
| - | include snippets/ | + | |
| - | try_files $fastcgi_script_name =404; # protects against CVE-2019-11043. If this line is already included in your snippets/ | + | |
| - | fastcgi_param HTTP_PROXY ""; | + | |
| - | fastcgi_pass unix:/ | + | |
| - | # | + | |
| - | } | + | |
| - | + | ||
| - | ## deny access to all other .php files | + | |
| - | location ~* ^.+\.php$ { | + | |
| - | deny all; | + | |
| - | return 403; | + | |
| - | } | + | |
| - | + | ||
| - | ## serve all other files normally | + | |
| - | location / { | + | |
| - | try_files $uri $uri/ =404; | + | |
| - | } | + | |
| - | + | ||
| - | ## disable all access to the following directories | + | |
| - | location ~ ^/ | + | |
| - | deny all; | + | |
| - | return 403; # replace with 404 to not show these directories exist | + | |
| - | } | + | |
| - | + | ||
| - | location ~ /\.ht { | + | |
| - | deny all; | + | |
| - | return 403; | + | |
| - | } | + | |
| - | + | ||
| - | location ~ js/ | + | |
| - | expires off; | + | |
| - | add_header Cache-Control ' | + | |
| - | } | + | |
| - | + | ||
| - | location ~ \.(gif|ico|jpg|png|svg|js|css|htm|html|mp3|mp4|wav|ogg|avi|ttf|eot|woff|woff2)$ { | + | |
| - | allow all; | + | |
| - | ## Cache images, | + | |
| - | ## Increasing the duration may improve the load-time, but may cause old files to show after an Matomo upgrade | + | |
| - | expires 1h; | + | |
| - | add_header Pragma public; | + | |
| - | add_header Cache-Control " | + | |
| - | } | + | |
| - | + | ||
| - | location ~ ^/ | + | |
| - | deny all; | + | |
| - | return 403; | + | |
| - | } | + | |
| - | + | ||
| - | ## properly display textfiles in root directory | + | |
| - | location ~/ | + | |
| - | default_type text/ | + | |
| - | } | + | |
| - | } | + | |
| - | # vim: filetype=nginx | + | |
| - | + | ||
| # | # | ||
| nginx -t | nginx -t | ||
| sudo systemctl restart nginx | sudo systemctl restart nginx | ||
| - | chown -R www-data: | ||
| </ | </ | ||
| - | 将 zip 文件解压缩到硬盘驱动器上的文件夹中。这将创建一个包含文件和目录的“matomo”文件夹。 | + | 浏览器访问 |
| - | + | ||
| - | 打开您的 FTP 客户端并将 Matomo 文件以“二进制模式”上传到 Web 服务器上的所需位置。例如,使用 Filezilla FTP 客户端,您可以在顶部菜单中启用二进制模式传输 传输 > | + | |
| 欢迎屏幕 | 欢迎屏幕 | ||
| 行 245: | 行 154: | ||
| 安装 JavaScript 跟踪标记 | 安装 JavaScript 跟踪标记 | ||
| - | 在您要分析的每个页面上安装 Matomo 生成的 JavaScript 跟踪标签。我们建议将此代码放在结束标记之前或包含在所有页面顶部的共享头文件中。</ | + | 在您要分析的每个页面上安装 Matomo 生成的 JavaScript 跟踪标签。建议将此代码放在结束标记之前或包含在所有页面顶部的共享头文件中</ |
| + | |||
| + | <code -> | ||
| + | vi / | ||
| + | |||
| + | < | ||
| + | |||
| + | <!-- Matomo --> | ||
| + | < | ||
| + | var _paq = window._paq = window._paq || []; | ||
| + | /* tracker methods like " | ||
| + | _paq.push([' | ||
| + | _paq.push([' | ||
| + | (function() { | ||
| + | var u="// | ||
| + | _paq.push([' | ||
| + | _paq.push([' | ||
| + | var d=document, g=d.createElement(' | ||
| + | g.async=true; | ||
| + | })(); | ||
| + | </ | ||
| + | <!-- End Matomo Code --> | ||
| + | |||
| + | </ | ||
| + | </code> | ||