インストールガイド · 6 min read · Oct 12, 2025
Ubuntu 20.04にMattermostチームメッセージングシステムをインストールする方法

Mattermostは、チャット、ファイル共有、検索、統合に使用されるオープンソースの自己ホスト型メッセージングアプリケーションです。これは、すべてのチームコミュニケーションを1つの場所に集約するSlackチャットの代替です。ReactとGolangで書かれており、バックエンドにはPostgreSQLまたはMySQLデータベースを使用しています。プッシュ通知、無制限の検索履歴、カスタム絵文字、Webhookおよびコマンド、アクティブディレクトリ、マルチノードデータベース展開サポート、フォーラム、ディスカッションボードなど、豊富な機能セットを提供しています。
このチュートリアルでは、Ubuntu 20.04にNginxとLet’s Encrypt SSLを使用してMattermostをインストールする方法を示します。
前提条件
- Ubuntu 20.04を実行しているサーバー。
- サーバーIPにポイントされた有効なドメイン名。
- サーバーに設定されたルートパスワード。
始めに
まず、システムパッケージを最新バージョンに更新することをお勧めします。次のコマンドを実行して更新できます。
apt-get update -yすべてのパッケージが更新されたら、次のコマンドを実行して他の必要な依存関係をインストールします。
apt-get install curl wget vim git unzip gnupg2 -yすべての必要なパッケージをインストールしたら、次のステップに進むことができます。
MariaDBのインストールと設定
Mattermostは、データベースバックエンドとしてMySQL/MariaDBを使用します。したがって、MariaDBサーバーをサーバーにインストールする必要があります。インストールされていない場合は、次のコマンドでインストールできます。
apt-get install mariadb-server -yMariaDBサーバーをインストールしたら、次のコマンドでMariaDBにログインします。
mysqlログインしたら、次のコマンドでMattermost用のデータベースとユーザーを作成します。
MariaDB [(none)]> CREATE DATABASE mattermostdb;
MariaDB [(none)]> CREATE USER 'mattermost'@'%' IDENTIFIED BY 'password';次に、次のコマンドでMattermostにすべての権限を付与します。
MariaDB [(none)]> GRANT ALL PRIVILEGES ON mattermostdb.* TO 'mattermost'@'%';次に、権限をフラッシュし、次のコマンドでMariaDBシェルから退出します。
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;MariaDBデータベースの設定が完了したら、次のステップに進むことができます。
Mattermostのインストールと設定
まず、公式ウェブサイトからMattermostの最新バージョンをダウンロードする必要があります。次のコマンドでダウンロードできます。
wget https://releases.mattermost.com/5.24.2/mattermost-5.24.2-linux-amd64.tar.gzダウンロードが完了したら、次のコマンドでダウンロードしたファイルを抽出します。
tar -xvzf mattermost-5.24.2-linux-amd64.tar.gz次に、抽出したディレクトリを/optにコピーします。
cp -r mattermost /opt次に、Mattermost用のデータディレクトリを作成します。
mkdir /opt/mattermost/data次に、Mattermostを実行するための別のユーザーを作成する必要があります。次のコマンドで作成できます。
useradd --system --user-group mattermost次に、Mattermostディレクトリの所有権をmattermostに変更し、次のコマンドで適切な権限を付与します。
chown -R mattermost:mattermost /opt/mattermost
chmod -R g+w /opt/mattermost次に、Mattermostのデフォルト設定ファイルを編集し、データベース設定とサイトURLを定義します。
nano /opt/mattermost/config/config.json必要に応じて次の行を変更します。
"SiteURL": "https://mattermost.linuxbuz.com",
"DriverName": "mysql",
"DataSource": "mattermost:password@tcp(localhost:3306)/mattermostdb?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s",完了したら、ファイルを保存して閉じます。
Mattermost用のSystemdサービスファイルを作成
次に、Mattermostサービスを管理するためのsystemdサービスファイルを作成する必要があります。次のコマンドで作成できます。
nano /lib/systemd/system/mattermost.service次の行を追加します。
[Unit]
Description=Mattermost
After=network.target
After=mysql.service
Requires=mysql.service
[Service]
Type=notify
User=mattermost
Group=mattermost
ExecStart=/opt/mattermost/bin/mattermost
TimeoutStartSec=3600
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost
LimitNOFILE=49152
[Install]
WantedBy=mariadb.serviceファイルを保存して閉じたら、次のコマンドでsystemdデーモンを再読み込みします。
systemctl daemon-reload次に、次のコマンドでMattermostサービスを開始し、システム再起動時に自動的に開始されるように有効にします。
systemctl start mattermost
systemctl enable mattermost次に、次のコマンドでMattermostサービスのステータスを確認します。
systemctl status mattermost次の出力が得られるはずです。
? mattermost.service - Mattermost
Loaded: loaded (/lib/systemd/system/mattermost.service; disabled; vendor preset: enabled)
Active: active (running) since Sat 2020-08-01 09:12:52 UTC; 17s ago
Main PID: 4106 (mattermost)
Tasks: 20 (limit: 2353)
Memory: 85.9M
CGroup: /system.slice/mattermost.service
??4106 /opt/mattermost/bin/mattermost
??4198 plugins/com.mattermost.nps/server/dist/plugin-linux-amd64
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.131499,"caller":"mlog/sugar.go:19","msg":"Sent notification of ne>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.1841655,"caller":"jobs/workers.go:73","msg":"Starting workers"}
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.1842792,"caller":"bleveengine/bleve.go:267","msg":"UpdateConf Ble>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.1930475,"caller":"jobs/schedulers.go:74","msg":"Starting schedule>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.20063,"caller":"app/web_hub.go:83","msg":"Starting websocket hubs>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.2099638,"caller":"app/license.go:37","msg":"License key from http>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.2205582,"caller":"app/server.go:525","msg":"Starting Server..."}
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.2208374,"caller":"app/server.go:594","msg":"Server is listening o>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.2211802,"caller":"commands/server.go:106","msg":"Sending systemd >
Aug 01 09:12:52 ubuntu2004 systemd[1]: Started Mattermost.この時点で、Mattermostは実行中でポート8065でリッスンしています。
Nginxをリバースプロキシとして設定
次に、MattermostのリバースプロキシとしてNginxを設定する必要があります。まず、次のコマンドでNginxパッケージをインストールします。
apt-get install nginx -yインストールが完了したら、次のコマンドでNginxの仮想ホスト設定ファイルを作成します。
nano /etc/nginx/sites-available/mattermost.conf次の行を追加します。
upstream mattermost {
server localhost:8065;
keepalive 32;
}
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off;
server {
listen 80;
server_name mattermost.linuxbuz.com;
location ~ /api/v[0-9]+/(users/)?websocket$ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
client_max_body_size 50M;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_buffers 256 16k;
proxy_buffer_size 16k;
client_body_timeout 60;
send_timeout 300;
lingering_timeout 5;
proxy_connect_timeout 90;
proxy_send_timeout 300;
proxy_read_timeout 90s;
proxy_pass http://mattermost;
}
location / {
client_max_body_size 50M;
proxy_set_header Connection "";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_buffers 256 16k;
proxy_buffer_size 16k;
proxy_read_timeout 600s;
proxy_cache mattermost_cache;
proxy_cache_revalidate on;
proxy_cache_min_uses 2;
proxy_cache_use_stale timeout;
proxy_cache_lock on;
proxy_http_version 1.1;
proxy_pass http://mattermost;
}
}ファイルを保存して閉じたら、次のコマンドで仮想ホスト設定を有効にします。
ln -s /etc/nginx/sites-available/mattermost.conf /etc/nginx/sites-enabled/mattermost.conf次に、次のコマンドでNginxの設定エラーを確認します。
ginx -t次の出力が得られるはずです。
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful最後に、次のコマンドでNginxサービスを再起動して変更を適用します。
systemctl restart nginxLet’s Encrypt SSLでMattermostを保護
まず、Let’s Encrypt SSLを管理するためにCertbotクライアントをシステムにインストールする必要があります。次のコマンドでインストールできます。
apt-get install python3-certbot-nginx -yCertbotをインストールしたら、次のコマンドを実行してウェブサイトのLet’s Encrypt SSLをインストールします。
certbot --nginx -d mattermost.linuxbuz.com有効なメールアドレスを提供し、次のようにサービス利用規約に同意するよう求められます。
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
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 at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing 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
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for mattermost.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/mattermost.conf次に、HTTPトラフィックをHTTPSにリダイレクトするかどうかを選択します。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 22を入力してEnterを押して、ドメインにLet’s Encrypt SSLをインストールします。インストールが完了すると、次の出力が表示されます。
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/mattermost.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://mattermost.linuxbuz.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=mattermost.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/mattermost.linuxbuz.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/mattermost.linuxbuz.com/privkey.pem
Your cert will expire on 2020-10-30. 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"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- 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
- We were unable to subscribe you the EFF mailing list because your
e-mail address appears to be invalid. You can try again later by
visiting https://act.eff.org.Mattermostウェブインターフェースにアクセス
今、ウェブブラウザを開いてURL https://mattermost.linuxbuz.com を入力します。Mattermostのサインアップ画面にリダイレクトされます。

メールアドレス、名前、パスワードを入力し、アカウントを作成ボタンをクリックします。次の画面が表示されるはずです。

チームを作成ボタンをクリックします。次の画面が表示されるはずです。

チーム名を入力し、次へボタンをクリックします。次の画面が表示されるはずです。

チームURLを入力し、完了ボタンをクリックします。Mattermostのウェルカム画面が表示されるはずです。

チュートリアルをスキップボタンをクリックします。次の画面にMattermostダッシュボードが表示されるはずです。

結論
このガイドでは、Ubuntu 20.04サーバーにMattermostチームメッセージングアプリケーションをインストールする方法を学びました。また、Nginxをリバースプロキシとして設定し、Let’s Encrypt SSLで保護する方法も学びました。これで、Mattermostのサービスを探索し、チームと一緒に作業することができます。
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。