Matomo是一个强大的网络分析平台,以其注重隐私的方法脱颖而出。通过在 Debian 12 服务器上自托管 Matomo,您可以完全控制您的数据,确保遵守数据保护法规。Matomo 提供了大量功能,包括实时跟踪、自定义报告和富有洞察力的仪表板,所有这些都旨在为您提供可操作的见解。
在 Debian 12 书虫上安装 Matomo
第 1 步。在我们安装任何软件之前,通过在终端中运行以下命令来确保您的系统是最新的非常重要:apt
<span class="pln">sudo apt update</span>
此命令将刷新存储库,允许您安装最新版本的软件包。
第 2 步。安装灯堆栈。
接下来,设置一个LAMP(Linux,Apache,MySQL,PHP)堆栈,这是托管Matomo的基础。最后,遵循最佳实践来保护服务器,保护您的数据免受潜在威胁:
<span class="pln">sudo apt install apache2 mysql</span><span class="pun">-</span><span class="pln">server php php</span><span class="pun">-</span><span class="pln">mysql</span>
增强服务器的安全性:
- 配置防火墙:使用
ufw
允许必要的端口并拒绝未经授权的访问。 - 安全MySQL:运行以设置root密码并删除不必要的用户。
mysql_secure_installation
- Harden Apache:调整设置以最大程度地减少漏洞。
现在 d从 Matomo 网站加载最新版本的 Matomo:
<span class="pln">cd </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html sudo wget https</span><span class="pun">:</span><span class="com">//builds.matomo.org/matomo.zip</span>
解压缩下载的文件并调整所有权:
<span class="pln">sudo unzip matomo</span><span class="pun">.</span><span class="pln">zip sudo chown </span><span class="pun">-</span><span class="pln">R www</span><span class="pun">-</span><span class="pln">data</span><span class="pun">:</span><span class="pln">www</span><span class="pun">-</span><span class="pln">data </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">matomo</span>
第 4 步。配置 MariaDB。
接下来,我们需要登录 MariaDB 控制台并为 Matomo 创建一个数据库。运行以下命令:
<span class="pln">mysql </span><span class="pun">-</span><span class="pln">u root </span><span class="pun">-</span><span class="pln">p</span>
这将提示您输入密码,因此请输入您的MariaDB root密码并按Enter键。登录到数据库服务器后,您需要为Matomo安装创建一个数据库:
<span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> CREATE DATABASE matomo_database</span><span class="pun">;</span> <span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> CREATE USER </span><span class="str">'matomo_user'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pln"> IDENTIFIED BY </span><span class="str">'your_strong_password'</span><span class="pun">;</span> <span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> GRANT ALL PRIVILEGES ON matomo_database</span><span class="pun">.*</span><span class="pln"> TO </span><span class="str">'matomo_user'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pun">;</span> <span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> FLUSH PRIVILEGES</span><span class="pun">;</span>
第5步。配置阿帕奇。
为 Matomo 创建新的虚拟主机配置文件:
<span class="pln">sudo nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">apache2</span><span class="pun">/</span><span class="pln">sites</span><span class="pun">-</span><span class="pln">available</span><span class="pun">/</span><span class="pln">matomo</span><span class="pun">.</span><span class="pln">conf</span>
将以下行添加到文件中:
<span class="tag"><VirtualHost</span><span class="pln"> *:80</span><span class="tag">></span><span class="pln"> ServerAdmin webmaster@localhost DocumentRoot /var/www/html/matomo ServerName your-domain.com </span><span class="tag"><Directory</span> <span class="pun">/</span><span class="atn">var</span><span class="pun">/</span><span class="atn">www</span><span class="pun">/</span><span class="atn">html</span><span class="pun">/</span><span class="atn">matomo</span><span class="tag">></span><span class="pln"> Options FollowSymLinks AllowOverride All Require all granted </span><span class="tag"></Directory></span><span class="pln"> ErrorLog ${APACHE_LOG_DIR}/matomo_error.log CustomLog ${APACHE_LOG_DIR}/matomo_access.log combined </span><span class="tag"></VirtualHost></span>
启用新的虚拟主机配置:
<span class="pln">sudo a2ensite matomo</span><span class="pun">.</span><span class="pln">conf</span>
重新启动 Apache :
<span class="pln">sudo systemctl restart apache2</span>
第 6 步。访问马托莫网络界面。
导航到服务器的 URL(例如,),然后按照基于 Web 的安装步骤进行操作。提供数据库详细信息,创建超级用户帐户,并根据需要自定义设置。http://your-domain.com/matomo
感谢您使用本教程在 Debian 12 书虫上安装最新版本的 Matomo。如需其他帮助或有用信息,我们建议您查看 Matomo 官方网站。