说明:Rocket.Chat
一年前就介绍过→传送门,一款多功能团队聊天室,支持群组聊天,直接通信,私聊群,桌面通知,媒体嵌入,链接预览,文件上传,语音/视频,聊天,截图,实时翻译等等,安装方法比较简单的有Snap
、Docker
,此前也只说过Snap
安装方法,由于一直有小伙伴需要宝塔面板安装教程,所以这里就水一篇宝塔教程。
安装
官方文档:https://rocket.chat/docs/
环境要求:NodeJS 8.11.4
、Mongodb 4.0.9
、Nginx
(非必需)。
提示:由于官方建议的最低内存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
安装完成后,进入面板,点击左侧软件商店,然后安装PM2管理器
、MongoDB
、Nginx
(使用域名访问才需要安装,反之不用)。
注意:Debian
安装MongoDb
之前还需要使用命令apt install sudo
,不然可能存在MongoDb
启动不了的情况;如果你已经安装了MongoDb
,那就先使用apt install sudo
,再使用/etc/init.d/mongodb start
启动即可。
2、环境配置
先点击左侧软件商店,找到PM2
管理器设置选项,选择Node
版本,切换到12.14.0
版本。
然后再找到MongoDb
设置选项,点击配置文件,新增/修改以下代码:
#设置storage引擎,新增engine参数,并修改下dbPath路径,不然会启动不了
storage:
dbPath: /www/server/mongodb/Rocket.Chat
directoryPerDB: true
engine: mmapv1
journal:
enabled: true
#配置replica set,新增以下参数
replication:
replSetName: rs01
保存后,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())"
3、安装依赖
#Debian/Ubuntu系统
apt install -y graphicsmagick
#CentOS系统
yum install -y GraphicsMagick
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
5、启动Rocket.Chat
ln -sf $(command -v node) /usr/bin/node
#新建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
开始启动:
#启动的时候,可能需要点时间加载,等待即可
systemctl start rocketchat
查看状态:
systemctl status rocketchat
开机自启:
systemctl enable rocketchat
此时访问地址为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;
}
点击保存后,再点击SSL
,申请免费的Let's Encrypt
证书,并强制HTTPS
。
配置好了后就可以使用域名访问了,然后根据要求安装好,最后就可以进入你的Rocket.Chat
聊天室了,还有更多使用方法可以直接查看→传送门。
我 又 来 了
这 次 我 是 来 问 怎 么 卸 载 的
去掉开机自启
systemctl stop rocketchat
systemctl disable rocketchat
再删掉源码目录就行了
申请证书老是说验证URL失败,我域名也解析指向了,是什么问题呢
看是不是申请的时候dns解析未生效,申请免费let常见也就这个原因了
之前用宝塔反代,结果手机 app 一直显示服务器端 websocket 未启用。
换成文章中的网站配置并取消反代后成功使用手机 app 登录,谢谢大佬!
请问Apache的反向代理的站点配置该怎么写呢
这个可以试着百度下
有没有视频教程啊??
在Ubantu上用Snap两行就解决了,然后换服务器,用了宝塔,又参考了你这个,安装成功,但是咋个把用Snap安装的数据备份还原到新机器上来,请指点.
看这个教程https://www.moerats.com/archives/530/,导出数据,然后导入过来看看,具体我没搞过,应该是可以的。
話說升級命令是哪個呀?
程序下载最新源码,解压,覆盖,安装依赖,启动,可参考:https://docs.rocket.chat/installation/manual-installation/updating
腾讯服务器
[root@VM_0_4_centos server]# npm i --unsafe-perm=true --allow-root
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
fibers@4.0.3 install /opt/Rocket.Chat/programs/server/node_modules/fibers
node build.js || nodejs build.js
linux-x64-72-glibc exists; testing
Problem with the binary; manual build incoming
make: 进入目录“/opt/Rocket.Chat/programs/server/node_modules/fibers/build”
CXX(target) Release/obj.target/fibers/src/fibers.o
make: g++:命令未找到
make: * [Release/obj.target/fibers/src/fibers.o] 错误 127
make: 离开目录“/opt/Rocket.Chat/programs/server/node_modules/fibers/build”
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/www/server/nvm/versions/node/v12.14.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 3.10.0-1062.18.1.el7.x86_64
gyp ERR! command "/www/server/nvm/versions/node/v12.14.0/bin/node" "/www/server/nvm/versions/node/v12.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
gyp ERR! cwd /opt/Rocket.Chat/programs/server/node_modules/fibers
gyp ERR! node -v v12.14.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
node-gyp exited with code: 1
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: sudo apt-get install g++ build-essential
RHEL users please run: yum install gcc-c++ and yum groupinstall 'Development Tools'
Alpine users please run: sudo apk add python make g++
sh: nodejs: 未找到命令
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! fibers@4.0.3 install: node build.js || nodejs build.js
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the fibers@4.0.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-06-17T13_43_31_073Z-debug.log
[root@VM_0_4_centos server]# sudo npm install
sudo: npm:找不到命令
[root@VM_0_4_centos server]# MongoDb
bash: MongoDb: 未找到命令...
pm i --unsafe-perm=true --allow-root这一步缺少依赖,试试这个命令yum -y groupinstall "Development Tools"
我试试,谢谢哈
腾讯云CentoS7.6 1核1G, 蓝米云手动部署可以,为什么同样方法腾讯的不行呢?
都是linux系统,与哪个服务器没啥关系,最多防火墙区别,你是运行不成功还是?
最新实测,建议萌鼠更新一下,最新版本要求node 10以上了,不过最近在一台1H1G的小鸡搭了以后感觉动不动100%,想搬家来着不知道是不是直接把数据库和文件夹移走就行了
好像已经支持到了12.14.0,搬家的话,是直接搬走数据文件夹就行
时隔半年我又双叒叕肥来惹,服务器CentOS 7.7.1908(Py2.7.5) node.js:8.11.4 MongoDB 4.0.10
安装依赖cd /opt/Rocket.Chat
npm install -g inherits
cd programs/server
npm install 安装到这一步
报错
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
fibers@4.0.3 install /opt/Rocket.Chat/programs/server/node_modules/fibers
node build.js || nodejs build.js
linux-x64-72-glibc exists; testing
Problem with the binary; manual build incoming
gyp WARN EACCES current user ("root1") does not have permission to access the dev dir "/root/.cache/node-gyp/12.16.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/opt/Rocket.Chat/programs/server/node_modules/fibers/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/opt/Rocket.Chat/programs/server/node_modules/fibers/.node-gyp'
gyp ERR! System Linux 3.10.0-1062.18.1.el7.x86_64
gyp ERR! command "/usr/bin/node" "/opt/Rocket.Chat/programs/server/node_modules/.bin/node-gyp" "rebuild" "--release"
gyp ERR! cwd /opt/Rocket.Chat/programs/server/node_modules/fibers
gyp ERR! node -v v12.16.2
gyp ERR! node-gyp -v v6.0.1
gyp ERR! not ok
node-gyp exited with code: 1
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: sudo apt-get install g++ build-essential
RHEL users please run: yum install gcc-c++ and yum groupinstall 'Development Tools'
Alpine users please run: sudo apk add python make g++
sh: nodejs: 未找到命令
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! fibers@4.0.3 install: node build.js || nodejs build.js
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the fibers@4.0.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-04-17T11_09_58_915Z-debug.log
大佬该怎么解决鸭?
好像是权限问题,试试npm i --unsafe-perm=true --allow-root
我用sudo npm install 成功运行下一步
但是吧 重启一次服务器后 MongoDb
又启动不了了
[root@haha ~]# /etc/init.d/mongodb start
about to fork child process, waiting until server is ready for connections.
forked process: 28033
ERROR: child process failed, exited with error number 14
To see additional information in this output, start without the "--fork" option.
这个需要看启动日志,宝塔应该有每个软件的日志信息显示