Rocket.Chat on Ubuntu

Recommended Fastest Server Install

We recommend installing using our Docker and Docker Compose guide or using Snaps as they are the easiest way for you to get your server up and running on all supported Linux distributions (Ubuntu, etc).
If you would like to enable TLS on your site like this https://yoursite.com when using the snap, please this guide

Manual install

This installation guide was tested in the following environment:
  • Rocket.Chat 4.6.0
  • OS: Ubuntu 18.04 LTS, Ubuntu 19.04 and Ubuntu 20.04(Latest)
  • 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!
Download the latest Rocket.Chat version:
1
curl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz
Copied!
1
tar -xzf /tmp/rocket.chat.tgz -C /tmp
Copied!
Install (this guide uses /opt but feel free to choose a different directory):
1
cd /tmp/bundle/programs/server && npm install --production
Copied!
If you're using the root account (not recommended), you'll have to use sudo npm install --unsafe-perm --production instead of the above.
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 node, the binary path may be different. Save it to a variable.
1
NODE_PATH=$(which node)
Copied!
Now save 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 firewall rule Configure a HTTP reverse proxy to access Rocket.Chat server [Configure mongo access control] [Configure production values for mongodb]

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 an admin account and your organization and server info.