LoginSignup
15
11

More than 5 years have passed since last update.

Mattermost のインストール for CentOS 7.2

Last updated at Posted at 2016-09-19

概要

Slackを使いたくても社内事情等々で利用できない場合に人気な、MattermostをLinux環境にれいる方法を書いてみました。
CentOS7.2をベースにPostgreSQLとnginxを利用しています。

前提条件

環境 バージョン
OS CentOS7.2
DB PostgreSQL 9.5.x
WebServer nginx

PostgreSQLおよびnginxは、あらかじめ以下よりインストールしておきましょう。
PostgreSQL 9.5.xをインストール(ソースからコンパイル)for CentOS 7.2
nginxインストール(ソースからコンパイル編)for CentOS7.2

インストール準備

DB作成

DBセットアップ
su postgres
psql
DBセットアップ
CREATE DATABASE mattermost;
CREATE USER mattermost WITH PASSWORD 'mattermost';
GRANT ALL PRIVILEGES ON DATABASE mattermost to mattermost;
\q
DBセットアップを終わる
exit

インストール

インストール作業
cd /usr/local/src
wget https://releases.mattermost.com/3.4.0/mattermost-team-3.4.0-linux-amd64.tar.gz
tar xvzf mattermost-team-3.4.0-linux-amd64.tar.gz

#ディレクトリを作成し、ファイルをコピーする
mkdir -p /docs/matt.exam.labo
cp -rf mattermost/* /docs/matt.exam.labo/

####ユーザーを作成する
useradd mattermost 
sudo chown -R mattermost:mattermost /docs/matt.exam.labo/

DB設定ファイルを設定

vi /docs/matt.exam.labo/config/config.json
設定
"SqlSettings": {
    "DriverName": "postgres", #<-PostgreSQLへ変更
    "DataSource": "postgres://mattermost:mattermost@localhost:5432/mattermost?sslmode=disable&connect_timeout=10",
    "DataSourceReplicas": [],
    "MaxIdleConns": 10,
    "MaxOpenConns": 10,
    "Trace": false,
    "AtRestEncryptKey": ""
},
  • DriverNameを「postgres」に変更
  • sslmode=disableを追加する

テスト実行

/docs/matt.exam.labo/bin/platform

実行
./platform
[2016/09/19 14:17:56 JST] [INFO] Loaded system translations for 'en' from '/docs/matt.exam.labo/i18n/en.json'
[2016/09/19 14:17:56 JST] [INFO] Current version is 3.4.0 (3.4.0/Wed Sep 14 13:19:13 UTC 2016/57f25fa59c71821cc38fd220b133aa6a40815e12/none)
[2016/09/19 14:17:56 JST] [INFO] Enterprise Enabled: false
[2016/09/19 14:17:56 JST] [INFO] Current working directory is /docs/matt.exam.labo/bin
[2016/09/19 14:17:56 JST] [INFO] Loaded config file from /docs/matt.exam.labo/config/config.json
[2016/09/19 14:17:56 JST] [INFO] Server is initializing...
[2016/09/19 14:17:56 JST] [INFO] Pinging sql master database
[2016/09/19 14:17:56 JST] [INFO] Pinging sql replica-0 database
[2016/09/19 14:17:56 JST] [INFO] The database schema has been set to version 3.4.0
[2016/09/19 14:17:56 JST] [DEBG] Deleting any unused pre-release features
[2016/09/19 14:17:56 JST] [DEBG] Initializing user api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing team api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing channel api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing post api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing web socket api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing file api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing command api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing admin api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing general api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing oauth api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing webhook api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing preference api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing license api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing emoji api routes
[2016/09/19 14:17:56 JST] [DEBG] Initializing status api routes
[2016/09/19 14:17:56 JST] [DEBG] Parsing server templates at /docs/matt.exam.labo/templates/
[2016/09/19 14:17:56 JST] [DEBG] Initializing web routes
[2016/09/19 14:17:56 JST] [DEBG] Using client directory at /docs/matt.exam.labo/webapp/dist/
[2016/09/19 14:17:56 JST] [INFO] Starting Server...
[2016/09/19 14:17:56 JST] [INFO] Server is listening on :8065
[2016/09/19 14:17:56 JST] [INFO] RateLimiter is enabled
[2016/09/19 14:17:56 JST] [DEBG] Checking for security update from Mattermost
[2016/09/19 14:18:27 JST] [DEBG] /
[2016/09/19 14:18:28 JST] [DEBG] /api/v3/users/initial_load

最後に、「[CRIT] Failed to ping db err:pq: SSL is not enabled on the server」が表示されている場合は、postgres://が付いているかと、sslmode=disableのパラメーターがあるを確認しましょう

ブラウザーを開き「http://server-ip:8065/」を開いてみましょう

image

のような画面が出ればサービスは正常起動しています。
一度、Ctrl+Cで、プロセスを終了します。

サービス設定

https://docs.mattermost.com/install/prod-rhel-7.html#id2
を参考にサービスファイルを定義します。

サービスファイル作成
vi /usr/lib/systemd/system/mattermost.service
サービススクリプト
[Unit]
Description=Mattermost
After=syslog.target network.target postgresql.service

[Service]
Type=simple
WorkingDirectory=/docs/matt.exam.labo/bin
User=mattermost
ExecStart=/docs/matt.exam.labo/bin/platform
PIDFile=/var/spool/mattermost/pid/master.pid

[Install]
WantedBy=multi-user.target

サービスを自動起動設定にして、サービスを起動します

サービス設定
systemctl enable mattermost
systemctl start mattermost

nginxを設定する

nginxは、既にインストール済みであることを想定しています。
configファイルに設定を追加し、mattermostの8065ポートをReverseProxyにする設定を入れます。

/etc/nginx/conf/nginx.conf
server {
    listen 80;
    server_name matt.exam.labo;

    location / {
        client_max_body_size 50M;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        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_pass http://127.0.0.1:8065;
    }
}

nginxサービスを再起動します

systemctl restart nginx

これで、ブラウザーで「http://server-ip/」でログインして、mattermostの設定画面が出ればOK!

参考

15
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
11