LoginSignup
16
20

More than 5 years have passed since last update.

Mattermost導入手順

Posted at

SlackクローンのMattermostをAmazonLinuxにインストールして使用する手順。

mysql5.6のインストール

最新のMattermostはmysql5.6以上でないと動作しない。
バージョン5.6をインストールするためリポジトリを追加。

wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
sudo yum install mysql-community-release-el6-5.noarch.rpm

正しくリポジトリが追加されたかを確認。
「MySQL 5.6 Community Server」が表示されていれば成功。

yum repolist

mysqlのインストール。

sudo yum install mysql-server
sudo /etc/init.d/mysqld start

Mattermost用のユーザーとスキーマを作成。

mysql -uroot
mysql > CREATE DATABASE mattermost;
mysql > GRANT ALL PRIVILEGES ON mattermost.* TO 'mattermost'@'localhost' IDENTIFIED BY 'mattermost' WITH GRANT OPTION;

MatterMostのインストール

mattermost実行ユーザーを作成。

sudo adduser mattermost

eMattermostの公式サイトでダウンロードできるバージョンを確認。
http://www.mattermost.org/download/

ダウンロード及び展開、配置。

wget https://releases.mattermost.com/3.1.0/mattermost-team-3.1.0-linux-amd64.tar.gz
tar zxvf mattermost-team-3.1.0-linux-amd64.tar.gz
sudo mv mattermost /opt/mattermost
sudo mkdir -p /opt/mattermost/data
sudo chown -R mattermost:mattermost /opt/mattermost
sudo chmod -R g+w /opt/mattermost

下記のファイルを編集し、Mattermostの設定を変更。
/opt/mattermost/config/config.json
DataSourceの項目を下記のように編集。

"DataSource": "mattermost:mattermost@tcp(localhost:3306)/mattermost?charset=utf8mb4,utf8",

※デフォルトだとDockerを使用する設定になっているので書き換える。

nginxのインストール及び設定

nginxのインストール及び起動設定。

sudo yum install nginx
sudo chkconfig nginx on
sudo /etc/init.d/nginx start

Mattermostの設定を追加。
下記のファイルを作成する。
/etc/nginx/conf.d/mattermost.conf

  server {
    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://localhost:8065;
    }
  }

※nginx.confにserverの設定が記述されていたらコメントアウトしておく

Mattermost自動起動設定

Mattermost起動スクリプトを下記場所に作成。
/opt/mattermost/bin/mattermost.sh

#!/bin/sh
# chkconfig:   - 85 15
# description:  mattermost

SERVICE=mattermost
start() {
    cd /opt/mattermost/bin
    sudo -u mattermost ./platform &
    echo "service $SERVICE [start]"
}
stop() {
    pkill platform
    echo "service $SERVICE [stop]"
}
status() {
   PID=`pgrep platform | wc -l`
   if [ $PID -eq 0 ]; then
       echo "$SERVICE stop"
   else
       echo "running $SERVICE ..."
   fi
}

case $1 in
start)
       start
       ;;
stop)
       stop
       ;;
status)
       status
       ;;
restart)
       stop
       start
       ;;
*)
       echo "Usage: $SERVICE [start|stop|restart|status]"
       ;;
esac
exit 0

権限の修正及びシンボリックリンクの作成。

sudo chmod 755 /opt/mattermost/bin/mattermost.sh
sudo ln -s /opt/mattermost/bin/mattermost.sh /etc/init.d/mattermost

Mattermostの起動。

sudo /etc/init.d/mattermost start

これで「 http://ホスト名 」にアクセスするとMattermostが開く。
追加でSSLやドメインの設定を行うのであればnginxで設定する。

16
20
1

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
16
20