宝塔面板安装Rocket.Chat聊天室

玩技站长 运维笔记评论591字数 3215阅读模式

说明:Rocket.Chat一年前就介绍过,一款多功能团队聊天室,支持群组聊天,直接通信,私聊群,桌面通知,媒体嵌入,链接预览,文件上传,语音/视频,聊天,截图,实时翻译等等,安装方法比较简单的有SnapDocker,此前也只说过Snap安装方法,由于一直有小伙伴需要宝塔面板安装教程,所以这里就水一篇宝塔教程。

安装

官方文档:https://rocket.chat/docs/文章源自玩技e族-https://www.playezu.com/21896.html

环境要求:NodeJS 8.11.4Mongodb 4.0.9Nginx(非必需)。文章源自玩技e族-https://www.playezu.com/21896.html

提示:由于官方建议的最低内存1G,所以512M或更小的建议加点虚拟内存,可以使用Swap一键脚本。文章源自玩技e族-https://www.playezu.com/21896.html

1、安装宝塔文章源自玩技e族-https://www.playezu.com/21896.html

  1. #CentOS系统
  2. wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
  3. #Ubuntu系统
  4. wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh
  5. #Debian系统
  6. wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && bash install.sh

安装完成后,进入面板,点击左侧软件商店,然后安装PM2管理器MongoDBNginx(使用域名访问才需要安装,反之不用)。文章源自玩技e族-https://www.playezu.com/21896.html

注意:Debian安装MongoDb之前还需要使用命令apt install sudo,不然可能存在MongoDb启动不了的情况;如果你已经安装了MongoDb,那就先使用apt install sudo,再使用/etc/init.d/mongodb start启动即可。文章源自玩技e族-https://www.playezu.com/21896.html

2、环境配置
先点击左侧软件商店,找到PM2管理器设置选项,选择Node版本,切换到8.11.4版本,不然太高可能会导致Rocket.Chat运行出错。文章源自玩技e族-https://www.playezu.com/21896.html

然后再找到MongoDb设置选项,点击配置文件,新增/修改以下代码:文章源自玩技e族-https://www.playezu.com/21896.html

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

保存后,MongoDb会自动关闭,这时候使用命令:文章源自玩技e族-https://www.playezu.com/21896.html

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

3、安装依赖文章源自玩技e族-https://www.playezu.com/21896.html

  1. #Debian/Ubuntu系统
  2. apt install -y graphicsmagick
  3. #CentOS系统
  4. yum install -y GraphicsMagick

4、安装Rocket.Chat

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

5、启动Rocket.Chat

  1. #新建rocketchat用户并授权
  2. useradd -M rocketchat && usermod -L rocketchat
  3. chown -R rocketchat:rocketchat /opt/Rocket.Chat
  4. #新建systemd配置文件,将以下代码一起复制到SSH运行
  5. cat > /etc/systemd/system/rocketchat.service <<EOF
  6. [Unit]
  7. Description=Rocket.Chat
  8. After=network.target
  9. Wants=network.target
  10. [Service]
  11. ExecStart=$(command -v node) main.js
  12. StandardOutput=syslog
  13. StandardError=syslog
  14. SyslogIdentifier=rocketchat
  15. User=rocketchat
  16. WorkingDirectory=/opt/Rocket.Chat
  17. 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
  18. Type=simple
  19. Restart=on-failure
  20. RestartSec=42s
  21. [Install]
  22. WantedBy=multi-user.target
  23. EOF

开始启动:

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

查看状态:

  1. systemctl status rocketchat

开机自启:

  1. systemctl enable rocketchat

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

6、域名访问
要使用域名的话就需要进行反代了,这里就不用宝塔自带的反向代理配置了,默认配置不适合Rocket.Chat

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

  1. location ~ ^/.* {
  2.     proxy_pass http://127.0.0.1:3000;
  3.     proxy_set_header Host             $host;
  4.     proxy_set_header X-Real-IP        $remote_addr;
  5.     proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
  6.     proxy_set_header Upgrade $http_upgrade;
  7.     proxy_set_header Connection "upgrade";
  8.     proxy_set_header X-Forward-Proto http;
  9.     proxy_set_header X-Nginx-Proxy true;
  10.     proxy_http_version 1.1;
  11.     proxy_redirect off;
  12. }

点击保存后,再点击SSL,申请免费的Let's Encrypt证书,并强制HTTPS

配置好了后就可以使用域名访问了,然后根据要求安装好,最后就可以进入你的Rocket.Chat聊天室了,还有更多使用方法可以直接查看→传送门

 

 

 

玩技站长微信
添加好友自动发送入群邀请
weinxin
rainbow-shownow
玩技官方公众号
官方微信公众号
weinxin
PLAYEZU
 最后更新:2021-11-30
  • 版权提示:本站仅供存储任何法律责任由作者承担▷诈骗举报◁▷新闻不符◁▷我要投稿◁
    风险通知:非原创文章均为网络投稿真实性无法判断,侵权联系2523030730
    免责声明:内容来自用户上传发布或新闻客户端自媒体,切勿!切勿!切勿!添加联系方式以免受骗。
  • 原创转载:https://www.playezu.com/21896.html
    转载说明: 点我前往阅读>>>
匿名

发表评论

匿名网友
确定