RocketChat简介
Rocket.Chat是一款开源的聊天软件。多client支持:Android,ISO,Windows,Mac,Linux,Web。安装部署简单、文档丰富,易于扩展。功能强大。支持群组聊天,私聊群,个人私聊,桌面通知,媒体嵌入,链接预览,文件上传,语音/视频聊天,截图等等。
项目开源地址:https://github.com/RocketChat
项目官方站点:https://rocket.chat
安装环境
CentOS7.5 win10
RocketChat的版本:v4.5.1(2022-3-12的最新版)
需要Node.js —v14.18.3,Mongodb (需要4.2以上),这里安装5.0.6版本。
公有云服务器可以,虚拟机上安装也可以,这里选择虚拟机安装。
开始安装
1、添加mongodb yum源仓库
cat << EOF | tee -a /etc/yum.repos.d/mongodb-org-5.0.repo[mongodb-org-5.0]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/5.0/x86_64/ #安装的5版本gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-5.0.ascEOF
2、添加node.js仓库
yum install -y curl && curl -sL https://rpm.nodesource.com/setup_12.x | bash -
3、安装nodejs mongodb-org
yum install -y gcc-c++ make nodejs mongodb-org
4、安装GraphicsMagick软件包
yum install -y epel-release && yum install -y GraphicsMagick
5、下载RocketChat源码包,并解压至/tmp目录下
curl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz
tar -xzf /tmp/rocket.chat.tgz -C /tmp
4、安装node,并选择版本
npm install -g inherits n
#如果你不知道刚才下载RocketChat源码包时需要node的啥版本,下面可以查看
[root@ecs-8e58 ~]# vi /tmp/bundle/README
This is a Meteor application bundle. It has only one external dependency:
Node.js v14.18.3. To run the application: #可以看到要求node是v14.18.3版本$ (cd programs/server && npm install)$ export MONGO_URL='mongodb://user:password@host:port/databasename'$ export ROOT_URL='http://example.com'$ export MAIL_URL='smtp://user:password@mailhost:port/'$ node main.jsUse the PORT environment variable to set the port where the
application will listen. The default is 80, but that will require
root on most systems.Find out more about Meteor at meteor.com.
#下面调整node的版本
n 14.18.3 #你没有看错,就是这条命令
5、安装RocketChat相应的模块:
#安装模块
cd /tmp/bundle/programs/server && npm install
#移动文件,换名
mv /tmp/bundle /opt/Rocket.Chat
#创建rocketchat用户
useradd -M rocketchat && usermod -L rocketchat
chown -R rocketchat:rocketchat /opt/Rocket.Chat #授权文件
6、设置RocketChat,有system启动
cat << EOF |sudo tee -a /lib/systemd/system/rocketchat.service[Unit]Description=The Rocket.Chat serverAfter=network.target remote-fs.target nss-lookup.target nginx.target mongod.target[Service]ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.jsStandardOutput=syslogStandardError=syslogSyslogIdentifier=rocketchatUser=rocketchat#注意:下面的那个IP,需要填写自己本机的IP,其它的不用修改
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01 MONGO_OPLOG_URL=mongodb://192.168.9.130:27017/local?replicaSet=rs01 ROOT_URL=http://localhost:3000/ PORT=3000[Install]WantedBy=multi-user.targetEOF
7、设置mongodb的引擎和复制操作
sed -i "s/^# engine:/ engine: mmapv1/" /etc/mongod.confsed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf
8、启动mongodb
systemctl restart mongod && systemctl enable mongodmongo --eval "printjson(rs.initiate())"
#查看mongodb启动的端口:
ss -ntpul
...
tcp LISTEN 0 128 127.0.0.1:27017 *:* users:(("mongod",pid=8437,fd=13))
...
9、启动rocketchat服务
systemctl restart rocketchat && systemctl enable rocketchat
#查看rocketchat启动的端口
ss -ntpul
...
tcp LISTEN 0 511 *:3000 *:* users:(("node",pid=9013,fd=47))
...
整体的Shell脚本如下:
[root@node1 ~]# cat aa.sh
#!/bin/bash
cat << EOF | tee -a /etc/yum.repos.d/mongodb-org-5.0.repo[mongodb-org-5.0]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/5.0/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-5.0.ascEOFyum install -y curl && curl -sL https://rpm.nodesource.com/setup_12.x | bash -yum install -y gcc-c++ make nodejs mongodb-orgyum install -y epel-release && yum install -y GraphicsMagickcurl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgztar -xzf /tmp/rocket.chat.tgz -C /tmpnpm install -g inherits n && n 14.18.3cd /tmp/bundle/programs/server && npm installmv /tmp/bundle /opt/Rocket.Chatuseradd -M rocketchat && usermod -L rocketchatchown -R rocketchat:rocketchat /opt/Rocket.Chatcat << EOF |sudo tee -a /lib/systemd/system/rocketchat.service[Unit]Description=The Rocket.Chat serverAfter=network.target remote-fs.target nss-lookup.target nginx.target mongod.target[Service]ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.jsStandardOutput=syslogStandardError=syslogSyslogIdentifier=rocketchatUser=rocketchatEnvironment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01 MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 ROOT_URL=http://192.168.9.130:3000/ PORT=3000[Install]WantedBy=multi-user.targetEOFsed -i "s/^# engine:/ engine: mmapv1/" /etc/mongod.confsed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.confsystemctl restart mongod && systemctl enable mongodmongo --eval "printjson(rs.initiate())"systemctl restart rocketchat && systemctl enable rocketchat
浏览器访问并配置登陆信息
浏览器输入:本地IP:3000
来看看聊天界面:
OK,RocketChat聊天服务就部署完成了,后续的聊天软件的使用下篇在更…