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 Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc
EOF
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
[root@ecs-8e58 ~]
This is a Meteor application bundle. It has only one external dependency:
Node.js v14.18.3. To run the application:
$ (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.js
Use 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.
n 14.18.3
5、安装RocketChat相应的模块:
cd /tmp/bundle/programs/server && npm install
mv /tmp/bundle /opt/Rocket.Chat
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 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://192.168.9.130:27017/local?replicaSet=rs01 ROOT_URL=http://localhost:3000/ PORT=3000
[Install]
WantedBy=multi-user.target
EOF
7、设置mongodb的引擎和复制操作
sed -i "s/^# engine:/ engine: mmapv1/" /etc/mongod.conf
sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf
8、启动mongodb
systemctl restart mongod && systemctl enable mongod
mongo --eval "printjson(rs.initiate())"
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
ss -ntpul
...
tcp LISTEN 0 511 *:3000 *:* users:(("node",pid=9013,fd=47))
...
整体的Shell脚本如下:
[root@node1 ~]
cat << EOF | tee -a /etc/yum.repos.d/mongodb-org-5.0.repo
[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc
EOF
yum install -y curl && curl -sL https://rpm.nodesource.com/setup_12.x | bash -
yum install -y gcc-c++ make nodejs mongodb-org
yum install -y epel-release && yum install -y GraphicsMagick
curl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz
tar -xzf /tmp/rocket.chat.tgz -C /tmp
npm install -g inherits n && n 14.18.3
cd /tmp/bundle/programs/server && npm install
mv /tmp/bundle /opt/Rocket.Chat
useradd -M rocketchat && usermod -L rocketchat
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=http://192.168.9.130:3000/ PORT=3000
[Install]
WantedBy=multi-user.target
EOF
sed -i "s/^# engine:/ engine: mmapv1/" /etc/mongod.conf
sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf
systemctl restart mongod && systemctl enable mongod
mongo --eval "printjson(rs.initiate())"
systemctl restart rocketchat && systemctl enable rocketchat
浏览器访问并配置登陆信息
浏览器输入:本地IP:3000
来看看聊天界面: OK,RocketChat聊天服务就部署完成了,后续的聊天软件的使用下篇在更…
|