Rocket.chat配置手册

snow chuai汇总、整理、撰写---2020/08/08


1. 安装MongoDB及Node.js
1) 更新系统
[root@srv1 ~]# yum update -y
2) 安装Mongodb [root@srv1 ~]# vim /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
3) 安装node.js [root@srv1 ~]# yum install curl -y && curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash
4) 安装一些必要的软件以及Mongodb、Nodejs [root@srv1 ~]# yum install gcc-c++ make mongodb-org nodejs -y
[root@srv1 ~]# yum install epel-release -y && yum --enablerepo=epel install GraphicsMagick -y
2. 安装Rocket.Chat
1) 下载Rocket.Chat
[root@srv1 ~]# curl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz
[root@srv1 ~]# tar -xzf /tmp/rocket.chat.tgz -C /tmp
2) 确认Rocket.Chat所使用的Node.js版本 [root@srv1 ~]# head /tmp/bundle/README | grep Node.js Node.js v12.16.1. To run the application:
3) 安装指定版本的Node.js版本 [root@srv1 ~]# npm config set registry https://registry.npm.taobao.org [root@srv1 ~]# npm install -g inherits n && n 12.16.1
4) 安装Rocket.Chat [root@srv1 ~]# cd /tmp/bundle/programs/server && npm install
[root@srv1 ~]# mv /tmp/bundle /opt/Rocket.Chat
5) 配置Rocket.Chat服务文件 [root@srv1 ~]# useradd -M rocketchat && usermod -L rocketchat [root@srv1 ~]# chown -R rocketchat:rocketchat /opt/Rocket.Chat [root@srv1 ~]# vim /usr/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=http://192.168.10.11:3000/ PORT=3000
[Install] WantedBy=multi-user.target

6) 启动MongoDB [root@srv1 ~]# sed -i "s/^# engine:/ engine: mmapv1/" /etc/mongod.conf [root@srv1 ~]# sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf [root@srv1 ~]# systemctl enable --now mongod
[root@srv1 ~]# mongo --eval "printjson(rs.initiate())" MongoDB shell version v4.0.19 connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb Implicit session: session { "id" : UUID("9d686e52-2676-4a75-8a0f-d2aae1623b90") } MongoDB server version: 4.0.19 { "info2" : "no configuration specified. Using a default configuration for the set", "me" : "127.0.0.1:27017", "ok" : 1, "operationTime" : Timestamp(1596827926, 1), "$clusterTime" : { "clusterTime" : Timestamp(1596827926, 1), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } } }
7) 启动Rocket.Chat [root@srv1 ~]# systemctl enable --now rocketchat
3. 安访问并配置Rocket.Chat
1) Rocket.Chat启动时间较长,等待系统启动。
2) 配置Rocket.Chat并添加新用户 [浏览器]===>http//$srv_ip:3000










3) 客户端---网页登录 [浏览器]===>http//$srv_ip:3000


4) 客户端软件 1. Linux 需要使用snap进行安装 2. MacOS以及iOS在App Store搜索rocket.chat进行安装 3. Android系统在"市场应用商店"搜索rocket.chat进行安装
4. 实现https及反向代理
1) 生成SSL证书
# 生成私钥并脱密
[root@srv1 ~]# cd /etc/pki/tls/certs
[root@srv1 ~]# openssl genrsa -des3 -out web.key 1024 Generating RSA private key, 1024 bit long modulus ......................................++++++ ..................................++++++ e is 65537 (0x10001) Enter pass phrase for web.key: # 输入密码 Verifying - Enter pass phrase for web.key: # 验证所输入的密码
[root@srv1 ~]# openssl rsa -in web.key -out web.key Enter pass phrase for web.key: # 输入刚才所设定的密码,脱密 writing RSA key
[root@srv1 ~]# chmod 400 web.key
# 生成证书 [root@srv1 ~]# openssl req -new -x509 -days 3650 -key web.key -out web.crt
You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:CN State or Province Name (full name) []:BeiJing Locality Name (eg, city) [Default City]:BeiJing Organization Name (eg, company) [Default Company Ltd]:1000cc Organizational Unit Name (eg, section) []:tech Common Name (eg, your name or your server's hostname) []:srv1.1000y.cloud Email Address []:
2) 配置Nginx [root@srv1 ~]# yum --enablerepo=epel install -y nginx
[root@srv1 ~]# vim /etc/nginx/nginx.conf # 在include /etc/nginx/conf.d/*.conf;语句后面追加绿色部分内容 ...... ...... include /etc/nginx/conf.d/*.conf;
# 定义代理 upstream rocket_backend { server 127.0.0.1:3000; }
# 定义Nginx所监听的端口及IP,并设置好SSL证书及代理名称 server { listen 2222 ssl; server_name 192.168.10.11; ssl_certificate /etc/pki/tls/certs/web.crt; ssl_certificate_key /etc/pki/tls/certs/web.key; location / { proxy_pass http://rocket_backend/; } }

server { .... ....
[root@srv1 ~]# systemctl enable --now nginx
3) 客户端访问方式 https://$srv_ip:2222

 

如对您有帮助,请随缘打个赏。^-^

gold