インストールガイド · 3 min read · Oct 12, 2025
Debian 11にMattermostをインストールする方法

Mattermostは、セキュリティを考慮して作成された無料のオープンソースのコラボレーションおよびメッセージングプラットフォームです。これはDiscordやSlackの代替であり、1対1のメッセージング、無制限の検索履歴とファイル共有機能、二要素認証、通知など、多くの便利な機能を提供します。これはGolangとReactで書かれた自己ホスト型のオンラインチャットサービスです。特に組織や企業向けに設計されており、チームがどこからでも安全にコミュニケーションできるようにします。
このチュートリアルでは、Debian 11にMattermostチャットサーバーをインストールする方法を示します。
前提条件
- Debian 11を実行しているサーバー。
- サーバーIPにポイントされた有効なドメイン名。
- サーバーに設定されたrootパスワード。
MariaDBデータベースサーバーのインストールと設定
Mattermostは、データベースバックエンドとしてMySQLまたはMariaDBを使用します。したがって、サーバーにMariaDBサーバーをインストールする必要があります。次のコマンドを使用してインストールできます。
apt-get install mariadb-server -yMariaDBがインストールされたら、MariaDBサービスを開始し、システム再起動時に自動的に開始するように設定します。
systemctl start mariadb
systemctl enable mariadb次に、次のコマンドを使用してMariaDBシェルに接続します。
mysql接続したら、次のコマンドを使用してデータベースとユーザーを作成します。
MariaDB [(none)]> create database mattermost;
MariaDB [(none)]> create user mattermost@localhost identified by 'password';次に、次のコマンドを使用してMattermostデータベースにすべての権限を付与します。
MariaDB [(none)]> grant all privileges on mattermost.* to mattermost@localhost;次に、権限をフラッシュし、次のコマンドを使用してMariaDBシェルから退出します。
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;完了したら、次のステップに進むことができます。
Mattermostのインストール
まず、次のコマンドを使用してMattermost用の専用ユーザーを作成します。
useradd --system --user-group mattermost次に、次のコマンドを使用してMattermostの最新バージョンをダウンロードします。
wget https://releases.mattermost.com/6.0.2/mattermost-6.0.2-linux-amd64.tar.gzダウンロードが完了したら、次のコマンドを使用してダウンロードしたファイルを抽出します。
tar -xvzf mattermost-6.0.2-linux-amd64.tar.gz次に、次のコマンドを使用して抽出したディレクトリを/optに移動します。
mv mattermost /opt次に、次のコマンドを使用してMattermost用のデータディレクトリを作成します。
mkdir /opt/mattermost/data次に、次のコマンドを使用してMattermostディレクトリの所有権を変更します。
chown -R mattermost:mattermost /opt/mattermost
chmod -R g+w /opt/mattermost次に、次のコマンドを使用してconfig.jsonファイルを編集します。
nano /opt/mattermost/config/config.json次の行を見つけます。
"DriverName": "postgres",
"DataSource": "postgres://mmuser:mostest@localhost/mattermost_test?sslmode=disable\u0026connect_timeout=10",そして、データベース設定に応じて次の行に置き換えます。
"DriverName": "mysql",
"DataSource": "mattermost:password@tcp(127.0.0.1:3306)/mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s",完了したら、ファイルを保存して閉じます。
Mattermost用のSystemdサービスファイルを作成
次に、Mattermost用のsystemdサービスファイルを作成する必要があります。次のコマンドを使用して作成できます。
nano /etc/systemd/system/mattermost.service次の行を追加します。
[Unit]
Description=Mattermost
After=syslog.target network.target mysqld.service
[Service]
Type=notify
WorkingDirectory=/opt/mattermost
User=mattermost
ExecStart=/opt/mattermost/bin/mattermost
PIDFile=/var/spool/mattermost/pid/master.pid
TimeoutStartSec=3600
LimitNOFILE=49152
[Install]
WantedBy=multi-user.targetファイルを保存して閉じたら、次のコマンドを使用してsystemdデーモンをリロードして変更を適用します。
systemctl daemon-reload次に、Mattermostを開始し、システム再起動時に自動的に開始するように設定します。
systemctl start mattermost
systemctl enable mattermost次に、次のコマンドを使用してMattermostのステータスを確認します。
systemctl status mattermost次の出力が得られます。
? mattermost.service - Mattermost
Loaded: loaded (/etc/systemd/system/mattermost.service; disabled; vendor preset: enabled)
Active: active (running) since Fri 2021-11-12 13:56:25 UTC; 4s ago
Main PID: 2888 (mattermost)
Tasks: 31 (limit: 4679)
Memory: 273.3M
CPU: 12.191s
CGroup: /system.slice/mattermost.service
??2888 /opt/mattermost/bin/mattermost
??2915 plugins/com.mattermost.plugin-channel-export/server/dist/plugin-linux-amd64
??2925 plugins/playbooks/server/dist/plugin-linux-amd64
??2931 plugins/focalboard/server/dist/plugin-linux-amd64
Nov 12 13:56:24 debian11 mattermost[2888]: {"timestamp":"2021-11-12 13:56:24.681 Z","level":"info","msg":"Scheduling next survey for Dec 3, 2>
Nov 12 13:56:25 debian11 mattermost[2888]: {"timestamp":"2021-11-12 13:56:25.064 Z","level":"info","msg":"Post.Message has size restrictions">
Nov 12 13:56:25 debian11 mattermost[2888]: {"timestamp":"2021-11-12 13:56:25.084 Z","level":"info","msg":"info [2021-11-12 13:56:25.083 Z] co>
Nov 12 13:56:25 debian11 mattermost[2888]: {"timestamp":"2021-11-12 13:56:25.131 Z","level":"info","msg":"\n -- collation of mattermost's >
Nov 12 13:56:25 debian11 mattermost[2888]: {"timestamp":"2021-11-12 13:56:25.491 Z","level":"info","msg":"debug [2021-11-12 13:56:25.488 Z] i>
Nov 12 13:56:25 debian11 mattermost[2888]: {"timestamp":"2021-11-12 13:56:25.777 Z","level":"info","msg":"info [2021-11-12 13:56:25.777 Z] Se>
Nov 12 13:56:25 debian11 mattermost[2888]: {"timestamp":"2021-11-12 13:56:25.963 Z","level":"info","msg":"Starting Server...","caller":"app/s>
Nov 12 13:56:25 debian11 mattermost[2888]: {"timestamp":"2021-11-12 13:56:25.964 Z","level":"info","msg":"Server is listening on [::]:8065",">
Nov 12 13:56:25 debian11 mattermost[2888]: {"timestamp":"2021-11-12 13:56:25.964 Z","level":"info","msg":"Sending systemd READY notification.>
Nov 12 13:56:25 debian11 systemd[1]: Started Mattermost.
MattermostのためのNginxをリバースプロキシとして設定
デフォルトでは、Mattermostはポート8065でリッスンします。したがって、ポート80でMattermostにアクセスするためにNginxをリバースプロキシとしてインストールおよび設定することをお勧めします。まず、次のコマンドを使用してNginxをインストールします。
apt-get install nginx -yNginxがインストールされたら、次のコマンドを使用してNginxの仮想ホスト設定ファイルを作成します。
nano /etc/nginx/conf.d/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.example.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;
}
}ファイルを保存して閉じたら、次のコマンドを使用して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 start nginx次のコマンドを使用してNginxのステータスを確認することもできます。
systemctl status nginx次の出力が得られるはずです。
? nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-11-12 13:57:02 UTC; 1min 12s ago
Docs: man:nginx(8)
Process: 3384 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 3392 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 3602 (nginx)
Tasks: 3 (limit: 4679)
Memory: 6.6M
CPU: 55ms
CGroup: /system.slice/nginx.service
??3602 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
??3604 nginx: worker process
??3605 nginx: worker process
Nov 12 13:57:01 debian11 systemd[1]: Starting A high performance web server and a reverse proxy server...
Nov 12 13:57:02 debian11 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Nov 12 13:57:02 debian11 systemd[1]: Started A high performance web server and a reverse proxy server.この時点で、Nginxはインストールされ、Mattermostのリバースプロキシとして設定されています。次のステップに進むことができます。
Mattermostウェブインターフェースにアクセス
今、ウェブブラウザを開き、URL http://mattermost.example.comを使用してMattermostウェブインターフェースにアクセスします。次のページにリダイレクトされます。

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

次に、システムコンソールに移動をクリックします。次のようにMattermostダッシュボードにリダイレクトされます。

結論
おめでとうございます!Nginxをリバースプロキシとして使用して、Debian 11にMattermostを正常にインストールしました。これで、組織内でMattermostを実装し、チームがどこからでも互いにコミュニケーションできるようにすることができます。
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。