如何在 Rocky Linux 9 上安装 Matomo

Linux命令 Edge插件网 2年前 (2023-03-11) 390次浏览 已收录 0个评论

Matomo(以前称为Piwik)是一款免费的开源网络分析软件。使用Matomo,您可以轻松跟踪,分析和报告您的网站流量。它是谷歌分析等其他商业分析平台的替代品,并且高度可定制、安全和私密。如何在 Rocky Linux 9 上安装 Matomo

在 Rocky Linux 9 上安装 Matomo

第 1 步。第一步是将系统更新到最新版本的软件包列表。为此,请运行以下命令:

<span class="pln">sudo dnf check</span><span class="pun">-</span><span class="pln">update
sudo dnf config</span><span class="pun">-</span><span class="pln">manager </span><span class="pun">--</span><span class="kwd">set</span><span class="pun">-</span><span class="pln">enabled crb</span>

第 2 步。安装阿帕奇。

默认情况下,Apache 在 Rocky Linux 9 基础存储库中可用。现在我们使用以下命令安装最新版本的 Apache:dnf

<span class="pln">sudo dnf install httpd httpd</span><span class="pun">-</span><span class="pln">tools</span>

您可以通过输入以下命令来启动服务并将其配置为在启动时运行:httpd

<span class="pln">sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl status httpd</span>

若要使页面向公众开放,必须使用以下命令编辑防火墙规则以允许 Web 服务器上的 HTTP 和 HTTPS 请求:

<span class="pln">sudo firewall</span><span class="pun">-</span><span class="pln">cmd </span><span class="pun">--</span><span class="pln">permanent </span><span class="pun">--</span><span class="pln">zone</span><span class="pun">=</span><span class="kwd">public</span> <span class="pun">--</span><span class="kwd">add</span><span class="pun">-</span><span class="pln">service</span><span class="pun">=</span><span class="pln">http 
sudo firewall</span><span class="pun">-</span><span class="pln">cmd </span><span class="pun">--</span><span class="pln">permanent </span><span class="pun">--</span><span class="pln">zone</span><span class="pun">=</span><span class="kwd">public</span> <span class="pun">--</span><span class="kwd">add</span><span class="pun">-</span><span class="pln">service</span><span class="pun">=</span><span class="pln">https 
sudo firewall</span><span class="pun">-</span><span class="pln">cmd </span><span class="pun">--</span><span class="pln">reload</span>

有关安装 Apache 的其他资源,请阅读下面的帖子:

  • 如何在 Rocky Linux √ 上安装 Apache。

第 3 步。安装 PHP。

PHP 是一种流行的脚本语言,可为数百万个网站和应用程序的动态内容提供支持。现在我们运行以下命令来安装 PHP:

<span class="pln">sudo dnf epel</span><span class="pun">-</span><span class="pln">release
sudo dnf install https</span><span class="pun">:</span><span class="com">//rpms.remirepo.net/enterprise/remi-release-9.rpm</span><span class="pln">
sudo dnf </span><span class="pun">--</span><span class="pln">disablerepo</span><span class="pun">=</span><span class="str">"*"</span> <span class="pun">--</span><span class="pln">enablerepo</span><span class="pun">=</span><span class="str">"remi-safe"</span><span class="pln"> list available 
sudo dnf </span><span class="kwd">module</span><span class="pln"> enable php</span><span class="pun">:</span><span class="pln">remi</span><span class="pun">-</span><span class="lit">8.1</span>

启用 Remi PHP 8.1 模块后,您现在可以安装 PHP 8.1 和常用的 PHP 扩展,如下所示:

<span class="pln">dnf install php php</span><span class="pun">-</span><span class="pln">cli php</span><span class="pun">-</span><span class="pln">mysqlnd php</span><span class="pun">-</span><span class="pln">opcache php</span><span class="pun">-</span><span class="pln">xml php</span><span class="pun">-</span><span class="pln">gd php</span><span class="pun">-</span><span class="pln">soap php</span><span class="pun">-</span><span class="pln">pdo php</span><span class="pun">-</span><span class="pln">bcmath php</span><span class="pun">-</span><span class="pln">intl php</span><span class="pun">-</span><span class="pln">mbstring php</span><span class="pun">-</span><span class="pln">json php</span><span class="pun">-</span><span class="pln">iconv php</span><span class="pun">-</span><span class="pln">zip unzip</span>

检查并验证已安装的版本:

<span class="pln">php </span><span class="pun">-</span><span class="pln">v</span>

有关安装 PHP 的其他资源,请阅读下面的帖子:

  • 如何在 Rocky Linux √ 上安装 PHP

第 4 步。安装 MariaDB。

默认情况下,MariaDB 在 Rocky Linux 9 基础存储库中可用。只需使用以下命令安装 MariaDB 软件包:dnf

<span class="pln">sudo dnf install mariadb</span><span class="pun">-</span><span class="pln">server mariadb</span>

安装完成后,启动数据库服务器的服务,然后启用相同的服务,以便它可以在系统重新启动时自动启动:

<span class="pln">sudo systemctl restart mariadb
sudo systemctl status mariadb
sudo systemctl enable mariadb</span>

默认情况下,MariaDB 未强化。您可以使用脚本保护 MariaDB。您应该仔细阅读并在每个步骤下方仔细阅读,这将设置root密码,删除匿名用户,禁止远程root登录,并删除测试数据库和对安全MariaDB的访问权限:mysql_secure_installation

<span class="pln">mysql_secure_installation</span>

首先,使用以下命令登录到 MariaDB shell:

<span class="pln">mysql</span>

现在我们使用以下命令为 Magento 创建一个数据库和用户:

<span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> CREATE DATABASE matomo</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'</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 ON matomo</span><span class="pun">.*</span><span class="pln"> TO </span><span class="str">'matomo'</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="pln"> WITH GRANT OPTION</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>
<span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span> <span class="kwd">exit</span><span class="pun">;</span>

有关安装 MariaDB 数据库的其他资源,请阅读以下帖子:

  • 如何在 Rocky Linux √ 上安装 MariaDB

第5步。在 Rocky Linux 9安装 Matomo

现在运行以下命令,从 Rocky Linux 系统的官方页面下载最新版本的 Matomo:

<span class="pln">wget https</span><span class="pun">:</span><span class="com">//builds.matomo.org/matomo-latest.zip</span>

接下来,使用以下命令提取 Matomo 包:

<span class="pln">tar xvf matomo</span><span class="pun">-</span><span class="pln">latest</span><span class="pun">.</span><span class="pln">zip</span>

我们需要更改一些文件夹权限:

<span class="pln">chown </span><span class="pun">-</span><span class="pln">R apache</span><span class="pun">:</span><span class="pln">apache </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
chmod </span><span class="pun">-</span><span class="pln">R </span><span class="lit">775</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>

第 6 步。配置阿帕奇。

现在我们使用以下命令配置 Matomo VirtualHost 文件:

<span class="pln">nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">httpd</span><span class="pun">/</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">d</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 admin@your-domain.com
   ServerName matomo.your-domain.com
   DocumentRoot /var/www/html/matomo/
   DirectoryIndex index.php

 </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 Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order allow,deny
   allow from all
 </span><span class="tag"></Directory></span><span class="pln">

   ErrorLog /var/log/httpd/matomo_error.log
   CustomLog /var/log/httpd/matomo_access.log combined
</span><span class="tag"></VirtualHost></span>

保存并关闭文件,然后重新启动 Apache 服务以应用更改:

<span class="pln">sudo systemctl restart httpd</span>

步骤 7.访问马托莫网络界面。

成功安装后,打开您的网络浏览器并使用 URL .您将被重定向到以下页面:http://your-domain.com

如何在 Rocky Linux 9 上安装 Matomo

感谢您使用本教程在您的 Rocky Linux 9 系统上安装 Matomo Web 分析。如需其他帮助或有用信息,我们建议您查看 Matomo 官方网站


Edge插件网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在 Rocky Linux 9 上安装 Matomo
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址