EC2のCentOS7にRocket.chatをインストール&NginxでSSL処理のメモ
【感想】
・構築自体はCentOS7を用意すれば、後述するさくらのナレッジに紹介された手順通りで構築可能。
・t2.microやt2.smallではCPUクレジットを一瞬で使い切って激重になるのでそれなりのスペックが必要。m4.largeあたりだと快適。
・Slackよりいたずらにリッチな感じ。音声メッセージって使う?
・WebRTC経由でのビデオチャットは正直まだ安定しているとはいいがたい。端末によってはカメラにアクセスできない場合もあり、まだまだβな雰囲気。
【記事作成時のバージョン】
>Stable: 0.46.0 22nd November 2016
>https://rocket.chat/releases/latest/download
【Rocket.Chatとは】
上記さくらのナレッジの記事より抜粋:
基本機能はほぼSlackと同様で、UIも似ている。また、WebブラウザだけでなくiOS/AndroidアプリやWindows/Mac OS X/Linux向けのデスクトップクライアントも提供されている点もSlackと近い。さらに音声/ビデオチャット機能やファイル共有機能、画面共有機能も備えている。
実装言語はNode.jsで、データベースにはMongoDBを採用。また、アプリケーションフレームワークにはMeteorが使われている。そのため、これらの技術に関する知識があればカスタマイズしやすい。
【CentOS7へのRocket.Chatインストール手順】
例によってさくらのナレッジをそのままコピペです……
※最初CentOS6やAmazonLinuxへのインストールを試みたのですが、どうしてもうまくいかずに諦めました。CentOS7ならいけたので以下にメモします。
SELINUX
vi /etc/sysconfig/selinux
→SELINUX=disabled : 無効にしておく(AmazonLinuxは初期値でdisabledだがCentOSはenableなので。)
インストールログ
# EPELより必要モジュールをインストール rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum install --enablerepo=epel mongodb-server nodejs npm curl GraphicsMagick # Rocket.Chat本体のインストール cd /usr/local/src curl -o rocket.chat.tgz -L https://rocket.chat/releases/latest/download tar xvzf rocket.chat.tgz mv bundle /opt/rocket.chat # 実行ユーザ「rocketchat」を追加 useradd -r rocketchat -U chown -R rocketchat:rocketchat /opt/rocket.chat # Systemdにサービス登録 # 環境ファイル作成 mkdir /etc/rocket.chat touch /etc/rocket.chat/rocketchat.env vi /etc/rocket.chat/rocketchat.env # ============================================================ MONGO_URL=mongodb://localhost:27017/rocketchat ROOT_URL=http://<サーバのIPなど>:3000/ PORT=3000 # ============================================================ # Systemdの設定ファイル作成 vi /etc/systemd/system/rocketchat.service # ============================================================ [Unit] Description=Rocket.Chat Server After=network-online.target mongod.target Requires=network-online.target [Service] ExecStart=/usr/bin/node /opt/rocket.chat/main.js EnvironmentFile=/etc/rocket.chat/rocketchat.env StandardOutput=syslog StandardError=syslog SyslogIdentifier=rocketchat User=rocketchat [Install] WantedBy=multi-user.target # ============================================================ # パッケージのディレクトリにて、npm installでnode.jsに必要なpackageをインストールする cd /opt/rocket.chat/programs/server/ npm install # systemctlコマンドで設定を反映させ、MongoDBおよびRocket.Chatを起動させる。 systemctl daemon-reload systemctl start mongod systemctl start rocketchat # 稼働サービスの確認 systemctl status rocketchat # サービス自動起動登録 systemctl enable mongod systemctl enable rocketchat # サービス自動起動登録状況確認 systemctl list-unit-files --type=service | grep mongo # mongod.service enabled systemctl list-unit-files --type=service | grep rocket # rocketchat.service enabled
【問題解決メモ】
さくらのナレッジの手順だけで進めた場合、rocketchatを開始すると以下のエラーが出た
systemctl status rocketchat
● rocketchat.service - Rocket.Chat Server Loaded: loaded (/etc/systemd/system/rocketchat.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since Wed 2016-12-07 16:35:30 JST; 13s ago Process: 12389 ExecStart=/usr/bin/node /opt/rocket.chat/main.js (code=exited, status=1/FAILURE) Main PID: 12389 (code=exited, status=1/FAILURE) Dec 07 16:35:30 rktcht.hogehoge.jp systemd[1]: Started Rocket.Chat Server. Dec 07 16:35:30 rktcht.hogehoge.jp systemd[1]: Starting Rocket.Chat Server... Dec 07 16:35:30 rktcht.hogehoge.jp systemd[1]: rocketchat.service: main process exited, code=exited, status=1/FAILURE Dec 07 16:35:30 rktcht.hogehoge.jp systemd[1]: Unit rocketchat.service entered failed state. Dec 07 16:35:30 rktcht.hogehoge.jp systemd[1]: rocketchat.service failed.
→パッケージのディレクトリにて、npm installを実行するとエラーは出なくなった
cd /opt/rocket.chat/programs/server/ npm install
SSL対応
Nginxを上に置いてSSL処理する。confは公式サイトのコピペ。
【参考】
https://rocket.chat/docs/installation/manual-installation/configuring-ssl-reverse-proxy#configuring-ssl-reverse-proxy
# epelからnginxインストール yum install nginx # SSL証明書配置 mkdir /etc/nginx/ssl hogehoge.comのpemとkeyを配置。 chmod 400 hogehoge.com.key chmod 400 hogehoge.com.pem # nginx.conf設定 vi /etc/nginx/conf.d/rktcht.conf #========================================================== # Upstreams upstream backend { server 127.0.0.1:3000; } # HTTPS Server server { listen 443; server_name hogehoge.com; error_log /var/log/nginx/hogehoge.com.access.log; ssl on; ssl_certificate /etc/nginx/ssl/hogehoge.com.pem; ssl_certificate_key /etc/nginx/ssl/hogehoge.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don’t use SSLv3 ref: POODLE location / { proxy_pass http://127.0.0.1:3000/; proxy_http_version 1.1; 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-Forward-For $proxy_add_x_forwarded_for; proxy_set_header X-Forward-Proto http; proxy_set_header X-Nginx-Proxy true; proxy_redirect off; } } #========================================================== nginx -t systemctl restart nginx # 自動起動確認 systemctl enable nginx # 確認 systemctl list-unit-files -t service | grep -e nginx # nginx.service enabled
■そのほかやったこと
設定項目が山盛りで何をどう設定したらベストなのかがさっぱりわからない。とりあえず以下の設定で運用中。
[メール]-[SMTP]で既存のSMTPサーバを指定。SMTPサーバ側にユーザも専用で作成した。
[全般]-[言語]で日本語を選択
[管理]-[メッセージ]-[検索に常に正規表現を使用する]
(あなたの言語が MongoDBの全文検索 でサポートされていない場合、これを有効にすることをお勧めします。)
をONに。デフォルトのままだと部分一致検索ができない。