Ubuntu 18.04.2 LTS Настройка GNOME 3.28.2
目次:
- 前提条件
- MySQLデータベースを作成する
- 新しいシステムユーザーを作成する
- Mattermostサーバーをインストールする
- Systemdユニットを作成する
- Nginxでリバースプロキシをセットアップする
- Mattermostの構成
- 結論
Mattermostは、エンタープライズグレードのインスタントメッセージングプラットフォームであり、オープンソースの自己ホスト型Slackの代替品です。 GolangとReactで書かれており、MySQLまたはPostgreSQLをデータベースバックエンドとして使用できます。 Mattermostは、すべてのチームコミュニケーションを1か所にまとめ、ファイル共有、1対1およびグループメッセージング、カスタム絵文字、ビデオ通話などのさまざまな機能を提供します。
このチュートリアルでは、MattermostをUbuntu 18.04サーバーにインストールし、NginxをSSLリバースプロキシとして構成します。
前提条件
このチュートリアルを続行する前に、次の前提条件を満たしていることを確認してください。
- sudo特権を持つユーザーとしてログインしています。サーバーのIPアドレスを指すドメイン名があります。
example.com
を使用しexample.com
。このガイドを確認しない場合、Nginxがインストールされています。ドメインにSSL証明書がインストールされています。 このガイドに従って、無料のLet's Encrypt SSL証明書をインストールできます。
MySQLデータベースを作成する
MySQLをMattermostのデータベースとして使用します。 サーバーにMySQLまたはMariaDBがインストールされていない場合は、次の手順に従ってインストールできます。
MySQLシェルにログインします。
mysql -u root
Mattermostインストールの新しいデータベースとユーザーを作成します。
CREATE DATABASE mattermost;
GRANT ALL ON mattermost.* TO mattermost@localhost IDENTIFIED BY 'P4ssvv0rD';
P4ssvv0rD
よりも安全なパスワードを使用していることを確認してください。
新しいシステムユーザーを作成する
Mattermostインスタンスを実行する新しいユーザーとグループを作成します。 ユーザーに
mattermost
名前を付けます:
sudo useradd -U -M -d /opt/mattermost mattermost
Mattermostサーバーをインストールする
この記事の執筆時点で、Mattermostの最新の安定バージョンはバージョン5.1.0です。 次のcurlコマンドを使用してアーカイブをダウンロードします。
sudo curl -L https://releases.mattermost.com/5.1.0/mattermost-5.1.0-linux-amd64.tar.gz -o /tmp/mattermost.tar.gz
ダウンロードが完了したら、アーカイブを抽出して
/opt
ディレクトリに移動し
/opt
sudo tar zxf /tmp/mattermost.tar.gz -C /opt
ファイル用のストレージディレクトリを作成します。
sudo mkdir -p /opt/mattermost/data
ディレクトリの所有権を最も
mattermost
ユーザーに変更します。
sudo chown -R mattermost: /opt/mattermost
/opt/mattermost/config/config.json
ファイルを開き、データベースドライバーを
mysql
設定し、データベース情報を入力します。
"SqlSettings": { "DriverName": "mysql", "DataSource": "mattermost:P4ssvv0rD@tcp(localhost:3306)/mattermost?charset=utf8mb4, utf8&readTimeout=30s&writeTimeout=30s",
Mattermostインスタンスが期待どおりに動作することを確認するために、Mattermostサーバーをテストします。
/opt/mattermost
ディレクトリに
/opt/mattermost
し、次のコマンドでサーバーを起動します。
cd /opt/mattermost
sudo -u mattermost bin/mattermost
すべてが正常に機能する場合、サーバーが起動し、出力は次のようになります。
{"level":"info", "ts":1532546921.941638, "caller":"app/server.go:115", "msg":"Starting Server…"} {"level":"info", "ts":1532546921.9421031, "caller":"app/server.go:154", "msg":"Server is listening on:8065"} {"level":"info", "ts":1532546921.9541554, "caller":"app/web_hub.go:75", "msg":"Starting 2 websocket hubs"}
CTRL+C
Mattermostサーバーを停止し、次の手順に進むことができます。
Systemdユニットを作成する
Mattermostインスタンスをサービスとして実行するには、
/etc/systemd/system/
ディレクトリに
mattermost.service
ユニットファイルを作成します。
テキストエディターを開き、次のファイルを作成します。
/etc/systemd/system/mattermost.service
Description=Mattermost After=network.target After=mysql.service Requires=mysql.service Type=notify ExecStart=/opt/mattermost/bin/mattermost TimeoutStartSec=3600 Restart=always RestartSec=10 WorkingDirectory=/opt/mattermost User=mattermost Group=mattermost LimitNOFILE=49152 WantedBy=mysql.service
systemdに新しいユニットファイルを作成したことを通知し、次のコマンドでMattermostサービスを開始します。
sudo systemctl daemon-reload
sudo systemctl start mattermost
これで、サービスステータスを確認できます。
sudo systemctl status mattermost
● mattermost.service - Mattermost Loaded: loaded (/etc/systemd/system/mattermost.service; disabled; ven Active: active (running) since Wed 2018-07-25 18:39:05 UTC; 41s ago Main PID: 3091 (mattermost) Tasks: 18 (limit: 507) CGroup: /system.slice/mattermost.service ├─3091 /opt/mattermost/bin/mattermost
エラーがない場合は、Mattermostサービスを有効にしてブート時に自動的に開始します。
sudo systemctl enable mattermost
Nginxでリバースプロキシをセットアップする
次に、Mattermostインスタンスに新しいサーバーブロックを設定する必要があります。 テキストエディターを開き、次のファイルを作成します。
/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+/(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; } }
変更を有効にするには、Nginxサービスをリロードします。
Mattermostの構成
ブラウザーを開き、ドメインを入力すると、sugnupページにリダイレクトされます。
メールアドレスを入力し、ユーザー名とパスワードを選択し、
Create Account
の
Create Account
ボタンをクリックして最初のアカウントを作成します。
SendinBlue、SendGrid、Amazon SES、Mandrill、Mailgun、Mailjet、Postmarkなどの一般的なトランザクションメールサービスを使用するか、このチュートリアルに従って独自のメールサーバーを設定できます。
最後に、変更を有効にするためにMattermostサービスを再起動する必要があります。
sudo systemctl restart mattermost
結論
Ubuntu 18.04サーバーにMattermostを正常にインストールし、Nginxをリバースプロキシとしてセットアップしました。 これで、Mattermostを使用してチームと共同作業を開始できます。
rocketchat nodejs Ubuntu