Rocket.Chat on Debian
This installation guide was tested in the following environment:
  • Rocket.Chat 4.6.0
  • OS: Debian 11, 10, 9
  • Mongodb 5.0
  • NodeJS 14.18.3

Requirements

Install Rocket.Chat

Install required packages/dependencies
1
sudo apt install -y curl build-essential graphicsmagick
Copied!
To download the latest Rocket.Chat version run the following command:
1
curl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz
Copied!
You can also use wget.
1
wget https://releases.rocket.chat/latest/download -O /tmp/rocket.chat.tgz
Copied!
You can also download a specific version by replacing latest by the version number. E.g.
1
wget https://releases.rocket.chat/4.1.2/download -O /tmp/rocket.chat.tgz
Copied!
Extract the archive with tar:
1
tar xzf /tmp/rocket.chat.tgz -C /tmp
Copied!
You should now see a new directory under /tmp named bundle.
Next, install all the node dependencies:
1
(cd /tmp/bundle/programs/server; npm i)
Copied!
If you're doing all this under the root user, which is not recommended, you'll need to pass the --unsafe-perm flag to npm along with sudo.
/tmp has been a temporary non-root user-writable location to prepare the bundle. For this guide, we're going to use /opt to be the final location but you can choose any other. Whatever may it be, if not/opt, make sure you change the location in all the other places it is specified.
1
sudo mv /tmp/bundle /opt/Rocket.Chat
Copied!

Configure the Rocket.Chat service

Add the rocketchat user, set the right permissions on the Rocket.Chat folder and create the Rocket.Chat service file:
1
sudo useradd -M rocketchat && sudo usermod -L rocketchat
Copied!
1
sudo chown -R rocketchat:rocketchat /opt/Rocket.Chat
Copied!
Depending on how you install NodeJs, the path to the binary can be different. Save the current path in a variable
1
NODE_PATH=$(which node)
Copied!
Now create the systemd service file
1
cat << EOF |sudo tee -a /lib/systemd/system/rocketchat.service
2
[Unit]
3
Description=The Rocket.Chat server
4
After=network.target remote-fs.target nss-lookup.target nginx.service mongod.service
5
[Service]
6
ExecStart=$NODE_PATH /opt/Rocket.Chat/main.js
7
StandardOutput=syslog
8
StandardError=syslog
9
SyslogIdentifier=rocketchat
10
User=rocketchat
11
[Install]
12
WantedBy=multi-user.target
13
EOF
Copied!
The command above will create a barebone service file, this service file is what systemd will use to start your Rocket.Chat daemon/process.

Passing environment variables

Next you need to pass some environment variables to the running process. For more information of configuring via environment variables read this article.
Run:
1
sudo systemctl edit rocketchat
Copied!
It should open up a text editor. Now write down the following,
1
[Service]
2
Environment=ROOT_URL=http://localhost:3000
3
Environment=PORT=3000
4
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01
5
Environment=MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01
Copied!
Change the values as you need. Save and exit.

MongoDB Configuration

Open the MongoDB config file (/etc/mongod.conf) in your favourite text editor. It is a simple YAML file.
Set the storage engine to wiredTiger.
1
storage:
2
engine: wiredTiger
Copied!
Enable replication, and name the replicaset rs01.
1
replication:
2
replSetName: rs01
Copied!
MongoDB replicaset is mandatory for Rocket.Chat > 1.0.0.
Your MongoDB config file should look something like the following:
1
storage:
2
dbPath: /var/lib/mongodb
3
journal:
4
enabled: true
5
engine: wiredTiger
6
7
systemLog:
8
destination: file
9
logAppend: true
10
path: /var/log/mongodb/mongod.log
11
12
net:
13
port: 27017
14
bindIp: 127.0.0.1
15
16
processManagement:
17
fork: true
18
timeZoneInfo: /usr/share/zoneinfo
19
20
replication:
21
replSetName: rs01
Copied!
For a full list of available MongoDB config options read their official documentation.
Start MongoDB with the following command:
1
sudo systemctl enable --now mongod
Copied!
Create the replicaset:
1
mongo --eval "printjson(rs.initiate())"
Copied!
You can start Rocket.Chat now.
1
sudo systemctl enable --now rocketchat
Copied!

Optional configurations

Configure your Rocket.Chat server

Open a web browser and access the configured ROOT_URL (http://your-host-name.com-as-accessed-from-internet:3000), follow the configuration steps to set up an admin account and your organization and server info.
Last modified 1mo ago
Was this page helpful?