我在ConoHa上搭建了RocketChat,所以留下了这个备忘录
我在ConoHa的CentOS7上搭建了RocketChat的环境,这是我的备忘录。
帐户和周围的内容并没有太大变化,可以参考以下链接:
https://qiita.com/fkds/items/f90d86837ef3a552924a
安装软件包
-
- Node: 8.11.4
-
- NPM: 6.4.1
- MongoDB: 4.0
$ sudo yum -y check-update
$ cat << EOF | sudo tee -a /etc/yum.repos.d/mongodb-org-4.0.repo
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
EOF
$ sudo yum install -y curl && curl -sL https://rpm.nodesource.com/setup_8.x | sudo bash -
$ sudo yum install -y gcc-c++ make mongodb-org nodejs
$ sudo yum install -y epel-release && sudo yum install -y GraphicsMagick
$ sudo npm install -g inherits n && sudo n 8.11.4
$ curl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz
$ tar -xzf /tmp/rocket.chat.tgz -C /tmp
$ cd /tmp/bundle/programs/server && npm install
$ sudo mv /tmp/bundle /opt/Rocket.Chat
Rocketchat的配置
请修改ROOT_URL。
$ sudo useradd -M rocketchat && sudo usermod -L rocketchat
$ sudo chown -R rocketchat:rocketchat /opt/Rocket.Chat
$ cat << EOF |sudo tee -a /lib/systemd/system/rocketchat.service
[Unit]
Description=The Rocket.Chat server
After=network.target remote-fs.target nss-lookup.target nginx.target mongod.target
[Service]
ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=rocketchat
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01 MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 ROOT_URL=https://hogehoge.site/ PORT=3000
[Install]
WantedBy=multi-user.target
EOF
$ sudo sed -i "s/^# engine:/ engine: mmapv1/" /etc/mongod.conf
$ sudo sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf
$ sudo systemctl enable mongod && sudo systemctl start mongod
$ mongo --eval "printjson(rs.initiate())"
$ sudo systemctl enable rocketchat && sudo systemctl start rocketchat
我想要以HTTPS显示
证明书的URL被放在头顶上供参考。
$ sudo yum -y install nginx
编辑 /etc/nginx/conf.d/default.conf
# Upstreams
upstream backend {
server 127.0.0.1:3000;
}
# Redirect Options
server {
listen 80;
server_name hogehoge.site;
# enforce https
return 301 https://$server_name$request_uri;
}
# HTTPS Server
server {
listen 443;
server_name hogehoge.site;
# You can increase the limit if your need to.
client_max_body_size 200M;
error_log /var/log/nginx/rocketchat.access.log;
ssl on;
ssl_certificate /etc/letsencrypt/live/hogehoge.site/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/hogehoge.site/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location / {
proxy_pass http://backend/;
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;
}
}
sudo systemctl enable nginx && sudo systemctl start nginx
RocketChat配置
如果您连接到https://hogehoge.site/,将会显示首次设置屏幕,您可以进行设置。
记事
某种原因导致无法上传图片的问题。
如果没有/tmp/ufs,就无法上传。(据说在CentOS7上会自动删除)
即使针对默认的GridFS和AWS S3,也会发生这种情况。
因此进行此设置。
#!/bin/sh
rc_tmp_dir=/tmp/ufs
if [ ! -e $rc_tmp_dir ]; then
mkdir -p $rc_tmp_dir && chmod 777 $rc_tmp_dir
fi
当前时间
0 * * * * /opt/hogehoge/upload_tmp.sh cd >/dev/null 2>&
重新启动服务
如果不按照顺序移动,它就不会动。
$ sudo systemctl stop nginx
$ sudo systemctl stop rocketchat
$ sudo systemctl stop mongod
$ sudo systemctl start mongod
$ sudo systemctl start rocketchat
$ sudo systemctl start nginx