TypechoJoeTheme

VPSGO服务器购!

[教程]宝塔面板安装Rocket.Chat在线聊天室

2021-09-12
/
0 评论
/
8,068 阅读
/
正在检测是否收录...
09/12

Rocket.Chat,有趣的聚会聊天室,支持社交聊天,直接通信,私聊群,桌面通知,媒体导入,链接预览,文件上传,语音/视频,聊天,截图,实时翻译等等,方安装行业释义法律。

安装

官方文档:https://rocket.chat/docs/

要环境是什么意思?:NodeJS 8.11.4Mongodb 4.0.9Nginx非必须)。

提示:由于官方建议的最低内存1G,因此有512M建议加点虚拟内存,可以使用Swap一键脚本→发送门。

1、安装宝塔

#CentOS系统 
wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh 
#Ubuntu系统 
wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh 
#Debian系统 
wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && bash install.sh
HTML


安装完成后,进入面板,点击左侧软件商店,然后安装PM2管理器MongoDBNginx使用才需要安装,反之不用)。

注意:Debian安装MongoDb之前还需要使用命令apt install sudo,其中可能存在MongoDb启动启动不了的情况;如果你已经安装了MongoDb,一起先使用apt install sudo,再使用/etc/init.d/mongodb start启动启动。

2、环境配置

先点击左侧软件商店,找到PM2管理器设置选项,选择Node版本,切换到8.11.4版本,习惯太高可能导致Rocket.Chat运行出错。

然后再找到MongoDb设置选项,点击配置文件,添加/修改以下代码:

#设置storage引擎,新增engine参数,并修改下dbPath路径,不然会启动不了 
storage:   
dbPath: /www/server/mongodb/Rocket.Chat  
directoryPerDB: true   
engine: mmapv1   journal:     
enabled: true 
#配置replica set,新增以下参数 
replication:   
replSetName: rs01 
HTML


保存后,MongoDb会自动关闭,这时候使用命令:

#新建数据存储路径,即上面配置文件修改的dbPath参数 
mkdir /www/server/mongodb/Rocket.Chat 
#授权 
chown mongo:mongo /www/server/mongodb/Rocket.Chat 
#重新启动数据库 
/etc/init.d/mongodb start #启动replica set mongo --eval "printjson(rs.initiate())"
HTML


3、安装依赖

#Debian/Ubuntu系统 
apt install -y graphicsmagick 
#CentOS系统 
yum install -y GraphicsMagick
HTML


4、安装Rocket.Chat

#下载rocket.chat 
wget -O rocket.chat.tgz https://releases.rocket.chat/latest/download  
#解压并删除 
tar -xzf rocket.chat.tgz && rm -rf rocket.chat.tgz 
#移动到/opt并重命名 
mv bundle /opt/Rocket.Chat 
#安装依赖 
cd /opt/Rocket.Chat 
npm install -g inherits 
cd programs/server 
npm install
HTML


5、启动Rocket.Chat

#新建rocketchat用户并授权 
useradd -M rocketchat && usermod -L rocketchat 
chown -R rocketchat:rocketchat /opt/Rocket.Chat 
#新建systemd配置文件,将以下代码一起复制到SSH运行 
cat > /etc/systemd/system/rocketchat.service <<EOF 
[Unit] 
Description=Rocket.Chat 
After=network.target 
Wants=network.target  
[Service] 
ExecStart=$(command -v node) main.js 
StandardOutput=syslog 
StandardError=syslog 
SyslogIdentifier=rocketchat 
User=rocketchat 
WorkingDirectory=/opt/Rocket.Chat 
Environment=MONGO_URL=mongodb://127.0.0.1:27017/rocketchat?replicaSet=rs01 MONGO_OPLOG_URL=mongodb://127.0.0.1:27017/local?replicaSet=rs01 ROOT_URL=http://127.0.0.1:3000/ PORT=3000 
Type=simple 
Restart=on-failure RestartSec=42s  
[Install] 
WantedBy=multi-user.target
EOF
HTML


开始启动:

#启动的时候,可能需要点时间加载,等待即可 
systemctl start rocketchat
HTML


查看状态:

systemctl status rocketchat
HTML


启动自启动:

systemctl enable rocketchat
HTML


此时访问地址为ip:3000,如果你想用ip访问,点击左侧安全,3000往端口浏览,如果想用域名访问,不用开启,继续看下。

6、域名访问

要使用域名的话就需要进行反代了,这里就不用宝塔自带的装备配置了,默认配置不适合Rocket.Chat

先点击左侧网站,添加站点,然后再点击添加站点的名称,这时候就进入了站点配置,点击配置文件,在中间添加以下代码:

location ~ ^/.* {
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header Host             $host;
    proxy_set_header X-Real-IP        $remote_addr;
    proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-Forward-Proto http;
    proxy_set_header X-Nginx-Proxy true;
    proxy_http_version 1.1;

    proxy_redirect off;
}
HTML


点击保存后,再点击SSL,申请免费的Let's Encrypt证书,并强制执行HTTPS
本文自Rat'Blog 和 转爱好者iNovel

教程客服Rocket.Chat
朗读
赞(0)
赞赏
感谢您的支持,我会继续努力哒!

三合一收款

下面三种方式都支持哦

微信
QQ
支付宝
打开支付宝/微信/QQ扫一扫,即可进行扫码打赏哦
版权属于:

VPSGO服务器购!

本文链接:

https://www.vpsgo.net/index.php/archives/31/(转载时请注明本文出处及文章链接)

评论 (0)