Matomo

提供: ArchWiki
2023年4月12日 (水) 16:44時点におけるKusanaginoturugi (トーク | 投稿記録)による版 (→‎Allow Matomo access to needed files: 飜訳)
ナビゲーションに移動 検索に移動

Matomo(旧 Piwik)は、GNU General Public License 3 でライセンスされたオープンソースのウェブ解析ツールです。このソフトウェアは PHP で書かれており、ウェブブラウザを介してアクセスします。プロジェクトの主要なアイデアはプライバシーであり、サードパーティのウェブサイト解析プロバイダを使用する場合、ウェブサイトのオーナーは、すべてのユーザーデータを広告主に売るために彼らに渡しています。

1 つの実行インスタンスで、対象ウェブサイトに JavaScript を読み込むことにより、複数のウェブサイトを解析することができます。

インストール

matomoAUR または matomo-gitAUR パッケージをインストールします。git パッケージは、php-fpm デーモンを自動的に設定します。さらに、最新の GeoIP データベースをダウンロードしてインストールします。デフォルトでは、Matomo は訪問者の位置を設定されたブラウザ言語から推測しますが、これは地理的位置に対する信頼性のある情報ではありません。

設定

php 設定

Matomo を動作させるためには、php を適切に設定する必要があります。

まず、PHP#MySQL/MariaDB で説明されているように、MySQL サポートを有効にしてください。/etc/php/php.ini を編集して、;extension=pdo_mysql;extension=mysqli の前のセミコロンを削除してコメントアウトを解除します。

一般的に、コメントは先行するセミコロンで示されます。

;extension=iconv を有効にし、;extension=gd は Matomo にとってオプションです。少なくとも iconv のコメントアウトを解除してください。

Matomo に必要なファイルへのアクセスを許可する

ノート: ここでの変更は matomoAUR パッケージにのみ必要で、すでにこのファイルを含む matomo-gitAUR には必要ありません。

バージョン7.4 以降の php-fpm.service に新たな制限があるため、ProtectSystem が設定されていて Matomo が正しく機能しない(プラグインのインストール、設定の変更などができない)場合、特定のファイルへのアクセス権を手動で設定する必要があります。

以下の /etc/systemd/system/php-fpm.service.d/override_matomo.conf ファイルは、必要以上のものを公開せず、インストールマニフェストで説明されているようにACLを変更できるようにしたまま、問題を解決します。

[Service]
ReadWritePaths = /usr/share/webapps/matomo/config
ReadWritePaths = /usr/share/webapps/matomo/matomo.js
ReadWritePaths = /usr/share/webapps/matomo/misc/user/
ReadWritePaths = /usr/share/webapps/matomo/plugins/

Server setup (nginx)

In order to enable php websites, install the php-fpm package and start/enable php-fpm.service (See Nginx#PHP implementation). Create the server by modifying /etc/nginx/nginx.conf. Add the following template to the "http" context. Alternatively, take a look at matomo's GitHub instructions.

include /etc/nginx/mime.types;

server
{
    index index.php;
    listen 443 ssl;
    listen [::]:443 ssl;
    root /usr/share/webapps/matomo/;
    server_name matomo.example.com;

    location ~ ^/(\.git/|config/|core/|lang/|tmp/)
    {
        return 403;
    }

    location ~ \.php$
    {
        try_files $uri =404;

        # FastCGI
        include fastcgi.conf;
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
    }

    location ~ \.(avi|css|eot|gif|htm|html|ico|jpg|js|json|mp3|mp4|ogg|png|svg|ttf|wav|woff|woff2)$
    {
        try_files $uri =404;
    }

    location ~ ^/(libs/|misc/|node_modules/|plugins/|vendor/)
    {
        return 403;
    }
}

To use encryption, you can get free certificates from letsencrypt. After requesting and installing your certificates, use them by adding the following code to the "http" or "server" context:

include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
ssl_certificate_key /etc/letsencrypt/live/subdomain.domain.me/privkey.pem;
ssl_certificate /etc/letsencrypt/live/subdomain.domain.me/fullchain.pem;

Run the nginx server by starting/enabling nginx.service.

ノート: mariadb.service and php-fpm.service are required.

Final steps

All major settings are done. Call your Matomo website in your browser and complete the small installation guide which is not more than checking that everything needed is available and set up and writing your configuration file.