Globe

Kratos
专注于用户阅读体验的响应式博客主题
  1. 首页
  2. 搭建教程
  3. 正文

Debain11 手动搭建 Rocket.Chat,让自己拥有自己的聊天工具

2023年10月10日 35点热度 0人点赞 0条评论

官网搭建地址
debain 官网搭建教程地址

需要注意步骤:
先安装mongodb :
步骤 1. 在运行下面的教程之前,通过apt在终端中运行以下命令来确保您的系统是最新的很重要:
apt update -y && apt upgrade -y

apt install -y curl apt-transport-https software-properties-common gnupg2

步骤 2. 安装 MongoDB。

默认情况下,MongoDB 在 Debian 11 基础存储库中不可用,现在将 MongoDB 存储库添加到您的 Debian 11 系统:

echo "deb http://repo.mongodb.org/apt/debian bullseye/mongodb-org/5.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
接下来,使用以下命令添加 GPG 密钥:

curl -sSL https://www.mongodb.org/static/pgp/server-5.0.asc -o mongoserver.asc
gpg --no-default-keyring --keyring ./mongo_key_temp.gpg --import ./mongoserver.asc
gpg --no-default-keyring --keyring ./mongo_key_temp.gpg --export > ./mongoserver_key.gpg
sudo mv mongoserver_key.gpg /etc/apt/trusted.gpg.d/

之后,使用以下命令刷新 APT 并安装 MongoDB:

sudo apt update
sudo apt install mongodb-org

让我们启用并启动数据库服务器的服务,这样我们就不需要在系统启动时一次又一次地运行它:

sudo systemctl enable --now mongod
sudo systemctl status mongod

要检查已安装的 MongoDB 版本:

mongod --version

下载或者移除:

sudo apt remove mongodb-org
sudo apt autoremove

mongo
连接后,使用以下命令创建名为 admin 的数据库:

use admin
然后,创建一个管理员用户并设置密码:

db.createUser(
{
user: "用户名",
pwd: "密码",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)

开启MongoDB的安全性,打开MongoDB的配置文件:

nano /etc/mongod.conf
添加以下几行:

security:
authorization: enabled
保存并关闭文件,然后重新启动 MongoDB 服务以应用更改:

sudo systemctl restart mongod
通过运行以下命令使用用户名和密码连接 MongoDB shell 来验证 MongoDB 连接:

mongo -u admin -p

接着安装nodejs:
12.x

# Using Debian, as root

curl -fsSL https://deb.nodesource.com/setup_12.x | bash -

apt-get install -y nodejs

V14.x:

1
2
3
<span class="pl-c"># Using Debian, as root</span><span class="text2Link">
curl -fsSL <a href="https://deb.nodesource.com/setup_14.x" target="_blank" rel="noopener">https://deb.nodesource.com/setup_14.x</a> </span><span class="pl-k">|</span> bash -
apt-get install -y nodejs

你也可以安装别的版本:
nodejs安装命令

查找node路径:
which node
会显示路径:/usr/bin/node

接着按照官网搭建教程开始搭建:

debain 官网搭建教程地址

其中有一步systemctl edit配置环境变量,可以使用下面方式:
mkdir -p /etc/systemd/system/rocketchat.service.d/
{ echo "[Service]";
echo "Environment=ROOT_URL=http://localhost:3000";
echo "Environment=PORT=3000";
echo "Environment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01";
echo "Environment=MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01";
} | sudo tee /etc/systemd/system/rocketchat.service.d/override.conf
systemctl daemon-reload

如果出现这个错误:
rocketchat.service: Main process exited, code=exited, status=203/EXEC

解决命令:
The problem is that your exec script is pointing to the wrong place , you can fix by providing a symlink to the actual location like this
ln -s /usr/bin/node /usr/local/bin/node or simple change it in the exec script

然后重启服务。

最后设置nginx进行反代:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
upstream backend {
    server 127.0.0.1:3000;
}
 
server {
    listen [::]:80;
    listen 80;
 
    server_name yourdomainname.com;
 
    client_max_body_size 200M;
 
    error_log /var/log/nginx/rocketchat.access.log;
 
    location / {
         proxy_pass http://backend/;
         proxy_set_header X-Forwarded-Host $host;
         proxy_set_header X-Forwarded-Server $host;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

proxy_pass http://localhost: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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forward-Proto http;
proxy_set_header X-Nginx-Proxy true;
proxy_redirect off;

标签: 暂无
最后更新:2023年10月10日

free

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2024 EverythingIThink. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang