ウェブ分析 · 4 min read · Nov 30, 2025
Debian 11にMatomoウェブ分析をインストールする方法

Matomo(以前はPiwikとして知られていた)は、開発者コミュニティによって開発された無料でオープンソースのウェブ分析アプリケーションです。これは、あなたのウェブサイトを追跡し、訪問者やその訪問者が使用した検索エンジンやキーワード、話す言語、好むページ、ダウンロードしたファイルなど、ウェブサイトに関する詳細な情報を提供します。Google AdWords、Facebook Ads、Yahoo、検索マーケティング、トラッキングおよびレポートAPI、クリック単価(CPC)など、多くの機能を提供しています。
このチュートリアルでは、Apache2ウェブサーバーと無料のLet’s Encrypt SSL証明書を使用して、Debian 11にMatomoをインストールする方法を示します。
前提条件
- Debian 11を実行しているサーバー。
- サーバーIPにポイントされた有効なドメイン名。
- サーバーに設定されたルートパスワード。
Apache、MariaDBおよびPHPのインストール
まず、Apacheウェブサーバー、MariaDBデータベースサーバー、PHPおよびその他のPHP拡張機能をサーバーにインストールする必要があります。次のコマンドを実行することで、すべてをインストールできます。
apt-get install apache2 mariadb-server php libapache2-mod-php php-cli php-fpm php-fpm php-json php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath curl unzip -yすべてのパッケージをインストールした後、次のコマンドを使用してApacheとMariaDBサービスを開始し、有効にします。
systemctl start apache2 mariadb
systemctl enable apache2 mariadb完了したら、次のステップに進むことができます。
Matomo用のMariaDBデータベースを作成
Matomoは、データベースバックエンドとしてMariaDBを使用します。したがって、Matomo用のデータベースとユーザーを作成する必要があります。
まず、次のコマンドでMariaDBにログインします。
mysqlログインしたら、次のコマンドでデータベースとユーザーを作成します。
MariaDB [(none)]> CREATE DATABASE matomodb;
MariaDB [(none)]> CREATE USER 'matomo'@'localhost' IDENTIFIED BY 'password';次に、次のコマンドでMatomoデータベースにすべての権限を付与します。
MariaDB [(none)]> GRANT ALL ON matomodb.* TO 'matomo'@'localhost' WITH GRANT OPTION;次に、権限をフラッシュし、次のコマンドでMariaDBシェルから退出します。
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;MariaDBデータベースの設定が完了したら、次のステップに進むことができます。
Matomoをダウンロード
次に、Matomoの公式ウェブサイトにアクセスし、次のコマンドで最新バージョンのMatomoをダウンロードします。
wget http://builds.matomo.org/matomo-latest.zipダウンロードが完了したら、次のコマンドでダウンロードしたファイルを解凍します。
unzip matomo-latest.zip次に、抽出したディレクトリをApacheのウェブルートディレクトリに移動します。
mv matomo /var/www/html/matomo次に、Matomoディレクトリの所有権と権限を変更します。
chown -R www-data:www-data /var/www/html/matomo
chmod -R 755 /var/www/html/matomo完了したら、次のステップに進むことができます。
Matomo用のApacheを設定
次に、インターネット上でMatomoをホストするためのApache仮想ホスト設定ファイルを作成する必要があります。次のコマンドで作成できます。
nano /etc/apache2/sites-available/matomo.conf次の行を追加します。
ServerAdmin [email protected]
ServerName matomo.example.com
DocumentRoot /var/www/html/matomo/
DirectoryIndex index.php
Options FollowSymLinks
AllowOverride All
Require all granted
Options None
Require all denied
Options None
Require all granted
Options None
Require all denied
Options None
Require all denied
ErrorLog ${APACHE_LOG_DIR}/matomo_error.log
CustomLog ${APACHE_LOG_DIR}/matomo_access.log combined
完了したらファイルを保存して閉じ、次のコマンドでMatomo仮想ホストとApacheリライトモジュールを有効にします。
a2ensite matomo.conf
a2enmod rewrite次に、変更を適用するためにApacheサービスを再起動します。
systemctl restart apache2次のコマンドでApacheのステータスを確認することもできます。
systemctl status apache2次の出力が得られます。
? apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2022-03-06 06:33:24 UTC; 5s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 55482 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 55486 (apache2)
Tasks: 6 (limit: 4679)
Memory: 12.4M
CPU: 108ms
CGroup: /system.slice/apache2.service
??55486 /usr/sbin/apache2 -k start
??55487 /usr/sbin/apache2 -k start
??55488 /usr/sbin/apache2 -k start
??55489 /usr/sbin/apache2 -k start
??55490 /usr/sbin/apache2 -k start
??55491 /usr/sbin/apache2 -k start
Mar 06 06:33:24 debian11 systemd[1]: Starting The Apache HTTP Server...
Mar 06 06:33:24 debian11 apachectl[55485]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 209>
Mar 06 06:33:24 debian11 systemd[1]: Started The Apache HTTP Server.
MatomoウェブUIにアクセス
今、ウェブブラウザを開き、URL http://matomo.example.comを使用してMatomoウェブインターフェースにアクセスします。次のページにリダイレクトされます。

次へボタンをクリックします。PHP設定チェックページが表示されるはずです。

すべての設定が正常であることを確認し、次へボタンをクリックします。MariaDBデータベース設定ページが表示されるはずです。

データベースサーバー、ユーザー名、データベース名、パスワードを提供し、次へボタンをクリックします。次のページが表示されるはずです。

次へボタンをクリックします。スーパーユーザー作成ページが表示されるはずです。

管理者のユーザー名、パスワード、メールアドレスを提供し、次へボタンをクリックします。ウェブサイト設定ページが表示されるはずです。

ウェブサイト名、URL、タイムゾーンを提供し、次へボタンをクリックします。次のページが表示されるはずです。


次へボタンをクリックします。設定確認ページが表示されるはずです。

Matomoに続行をクリックします。Matomoのログインページが表示されるはずです。

管理者のユーザー名、パスワードを提供し、サインインボタンをクリックします。次のページにMatomoダッシュボードが表示されます。上の画像に表示されているトラッキングコードをコピーし、あなたのウェブサイトのすべてのページに貼り付けることができます。

Let’s Encrypt SSLでMatomoを保護
次に、ウェブサイト用のLet’s Encrypt SSLをインストールするためにCertbotクライアントをインストールする必要があります。次のコマンドでインストールできます。
dnf install epel-release -y dnf install certbot python3-certbot-apache次に、次のコマンドであなたのドメインに対してSSL証明書を取得し、インストールします。
certbot --apache -d matomo.example.comメールアドレスを提供し、利用規約に同意するよう求められます。
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel): [email protected]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued,
to share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Account registered.
Requesting a certificate for matomo.example.com
Performing the following challenges:
http-01 challenge for matomo.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/httpd/conf.d/matomo.conf
Redirecting all traffic on port 80 to ssl in /etc/httpd/conf.d/matomo.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://matomo.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Subscribe to the EFF mailing list (email: [email protected]).
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/matomo.example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/matomo.example.com/privkey.pem
Your certificate will expire on 2022-05-09. To obtain a new or
tweaked version of this certificate in the future, simply run
certbot again with the "certonly" option. To non-interactively
renew *all* of your certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le結論
おめでとうございます!Debian 11にMatomoを正常にインストールしました。これで、ウェブサイトにトラッキングコードを追加し、Matomoダッシュボードから監視を開始できます。質問があればお気軽にお尋ねください。
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。