
この記事では、Ubuntu 18.04 LTS に Mattermost をインストールして構成するために必要な手順について説明しました。このチュートリアルを続行する前に、sudo 権限を持つユーザーとしてログインしていることを確認してください。このチュートリアルのすべてのコマンドは、root 以外のユーザーとして実行する必要があります。
Mattermost は、React と Golang で書かれたオープンソース プラットフォームです。代替メッセージング プラットフォームとして使用でき、バックエンドで PostgreSQL または MySQL データベースを利用します。最も重要な主な機能は、チームのコミュニケーションをまとめ、ファイル共有、カスタム絵文字、ビデオ通話、メッセージング (1 対 1 またはグループ) などのいくつかの機能を提供することです。
Mattermost を Ubuntu 18.04 にインストール
ステップ 1. まず、Ubuntu サーバーにパッケージのインストールを開始する前に、すべてのシステム パッケージが更新されていることを確認することを常にお勧めします。
sudo apt update sudo apt upgrade
ステップ 2. MySQL データベースをインストールします。
次のコマンドで MySQL パッケージをインストールします:
sudo apt install mysql-server
MySQL サーバー パッケージには、いくつかのセキュリティ関連の操作を実行できる mysql_secure_installation というスクリプトが付属しています。次のように入力してスクリプトを実行します。
sudo mysql_secure_installation
次に、Mattermost インストール用の新しいデータベースとユーザーを作成します。
$ mysql -u root CREATE DATABASE mattermost; GRANT ALL ON mattermost.* TO example@unixlinux.online IDENTIFIED BY 'PassWD';
ここで、Mattermost インスタンスのために新しいシステム ユーザーとグループを作成します。この場合、ユーザーをマターモストと名付けます:
sudo useradd -U -M -d /opt/mattermost mattermost
ステップ 3. Mattermost を Ubuntu にインストールします。
まず、安定した最新の Mattermost バージョンをダウンロードします:
sudo curl -L https://releases.mattermost.com/5.1.0/mattermost-5.1.0-linux-amd64.tar.gz -o /tmp/mattermost.tar.gz sudo tar zxf /tmp/mattermost.tar.gz -C /opt sudo mkdir -p /opt/mattermost/data
ディレクトリの所有権を最も重要なユーザーに変更してください:
sudo chown -R mattermost: /opt/mattermost
次に、/opt/mattermost/config/config.json ファイルを開き、データベース ドライバーを mysql に設定し、データベース情報を入力します:
nano /opt/mattermost/config/config.json
"SqlSettings": {
"DriverName": "mysql",
"DataSource": "mattermost:example@unixlinux.online(localhost:3306)/mattermost?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s", ここで、Mattermost サーバーが正常に動作しているかどうかをテストする必要があります。これを行うには、/opt/mattermost ディレクトリに移動し、以下のコマンドを実行してサーバーを起動します:
cd /opt/mattermost sudo -u mattermost bin/mattermost
ステップ 4. Systemd ユニットの作成。
/etc/systemd/system/ ディレクトリに mattermost.service ユニット ファイルを作成します:
nano /etc/systemd/system/mattermost.service
[Unit] Description=Mattermost After=network.target After=mysql.service Requires=mysql.service [Service] Type=notify ExecStart=/opt/mattermost/bin/mattermost TimeoutStartSec=3600 Restart=always RestartSec=10 WorkingDirectory=/opt/mattermost User=mattermost Group=mattermost LimitNOFILE=49152 [Install] WantedBy=mysql.service
次に、以下のコマンドを使用して Mattermost サービスを再起動します:
sudo systemctl daemon-reload sudo systemctl start mattermost sudo systemctl enable mattermost
ステップ 5. Nginx を使用してリバース プロキシをセットアップします。
nginx をインストールしていない場合は、次のチュートリアルに従ってください。ここで、Mattermost インスタンス用に新しいサーバー ブロックを設定する必要があります:
nano /etc/nginx/conf.d/example.com.conf
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off;
upstream mattermost_backend {
server 127.0.0.1:8065;
}
server {
listen 80;
server_name example.com www.example.com;
include snippets/letsencrypt.conf;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl http2;
server_name www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
include snippets/ssl.conf;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl http2;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
include snippets/ssl.conf;
access_log /var/log/nginx/example.com-access.log;
error_log /var/log/nginx/example.com-error.log;
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;
proxy_read_timeout 600s;
proxy_pass http://mattermost_backend;
}
location / {
proxy_http_version 1.1;
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_pass http://mattermost_backend;
}
} ステップ 6. Mattermost にアクセスします。
Mattermost サービスを設定するには、ブラウザに移動してドメイン名を入力すると、サインアップ ページが表示されます。
Ubuntu 18.04 に Mattermost をインストールするために必要なことはこれだけです。この簡単なヒントがお役に立てば幸いです。ご質問やご提案がありましたら、お気軽にコメントを残してください。