How to Install Rocket.Chat Server on Ubuntu Linux
Rocket.Chat server installation on Ubuntu Linux sets up your own private communication platform.
Rocket.Chat is a free, self-hosted chat app. It lets you fully control your team’s collaboration, like Slack but with your data staying with you.
It provides real-time messaging, file sharing, and video calls. This tutorial covers setup for Ubuntu 16.04 or 18.04 LTS.
Install MongoDB by adding its repository, then updating and installing the package. Configure MongoDB for replication and restart the service. Install Node.js and npm using apt.
Install MongoDB
To install Rocket.Chat on Ubuntu, you first need to install MongoDB, which is the database program that Rocket.Chat uses. We’ll add the official MongoDB software source to your system so you get the latest version. Then, we’ll run a command to add its security key, getting your system ready for the MongoDB installation.
To get the latest version of MongoDB, you must add its repository to Ubuntu. To do that, run the commands below to add the official repository key.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
After adding the repository key to Ubuntu, run the commands below to add the MongoDB repository to your system…
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
Now that the repository and key have been added to Ubuntu run the commands below to install the package.
sudo apt update sudo apt install -y mongodb-org
After installing MongoDB, the commands below can be used to stop, start, and enable MongoDB to automatically startup when the system boots up.
sudo systemctl stop mongod.service sudo systemctl start mongod.service sudo systemctl enable mongod.service
By default, MongoDB listens on port 27017. After installation, the local server should be able to communicate with MongoDB. To verify whether MongoDB is running and active, run the commands below:
sudo systemctl status mongod
You should see something like the lines below:
richard@ubuntu1604:~$ sudo systemctl status mongod
● mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2018-01-27 08:53:42 CST; 13min ago
Docs: https://docs.mongodb.org/manual
Main PID: 2383 (mongod)
Tasks: 23
Memory: 60.7M
CPU: 2.613s
CGroup: /system.slice/mongod.service
└─2383 /usr/bin/mongod --config /etc/mongod.conf
Jan 27 08:53:42 ubuntu1604 systemd[1]: Started High-performance, schema-free document-oriented database.
Jan 27 09:05:49 ubuntu1604 systemd[1]: Started High-performance, schema-free document-oriented database.
Configure MongoDB
After installing MongoDB, you must configure it as a replica set for Rocket.Chat to work correctly. This means making specific changes in the MongoDB settings file. We will guide you on how to open this file and add the lines needed to set up the replica set. Always check Rocket.Chat’s release notes for the right MongoDB version to use.
Add this section into /etc/mongod to configure the replica set.conf:
sudo nano /etc/mongod.conf
Then copy and paste the lines at the end of the file and save.
replication: replSetName: "rs01"
You can accomplish the same settings above by running the command below:
echo -e "replication:n replSetName: "rs01"" | sudo tee -a /etc/mongod.conf
After running the commands above, run this to restart the MongoDB service:
sudo systemctl restart mongod
Next, start the MongoDB shell
mongo
Then, the commands below to initiate the replica set
rs.initiate()
The output of the command should look like this:
{
"operationTime" : Timestamp(1562351876, 1),
"ok" : 0,
"errmsg" : "already initialized",
"code" : 23,
"codeName" : "AlreadyInitialized",
"$clusterTime" : {
"clusterTime" : Timestamp(1562351876, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}
Exit, and you’re done with MongoDB.
Install Node.js
Rocket.Chat needs Node.js to run, so installing it on your Ubuntu computer is the next important step. We will also install npm and build-essential, which are necessary tools for this process. After getting Node.js, we’ll run commands to install the specific Node version that Rocket.Chat recommends for the best performance.
sudo apt install nodejs npm build-essential curl software-properties-common graphicsmagick
After that, run the commands to get the recommended node and n packages.
sudo npm install -g inherits n && sudo n 8.11.4
After installing, both Node.js and NPM modules should be installed and ready to use….
Install Rocket.Chat Server
With MongoDB and Node.js ready, you can now install the Rocket.Chat server on Ubuntu. It’s best to create a new user just for Rocket.Chat, rather than using your main account. We will show you the command to create this new user, and then you will switch to that user to finish installing Rocket.Chat.
First, run the commands below to create a new user account for Rocket. Chat. You probably don’t want to run it as root.
sudo useradd -m -U -r -d /opt/rocketchat rocketchat
Switch over to the rocket user:
sudo su - rocketchat
The following commands assume you are operating as a user rocket chat.
The latest Rocket.Chat server package downloads to the `rocketchat` user's home directory on Ubuntu Linux. Downloading this package is a necessary step for installing the Rocket.Chat server software, a communication platform used by over 12 million people.
curl -L https://releases.rocket.chat/latest/download -o rocket.chat.tgz
Once it is downloaded, extract the Rocket.Chat archive and run npm install:
tar zxvf rocket.chat.tgz mv bundle Rocket.Chat cd /opt/rocketchat/Rocket.Chat/programs/server npm install
After that, run the lines below:
export ROOT_URL=http://example.com:3000
export MONGO_URL=mongodb://localhost:27017/rocketchat
export MONGO_OPLOG_URL=mongodb://localhost:27017/local?replSet=rs01
export PORT=3000Then, change into the Rocketchat home directory.
cd /opt/rocketchat/Rocket.Chat/
Run the commands below.
node main.js
If everything runs as expected. You should see the status of the server running.
➔ System ➔ startup
➔ +---------------------------------------------+
➔ | SERVER RUNNING |
➔ +---------------------------------------------+
➔ | |
➔ | Rocket.Chat Version: 1.2.1 |
➔ | NodeJS Version: 8.11.4 - x64 |
➔ | MongoDB Version: 4.0.10 |
➔ | MongoDB Engine: wiredTiger |
➔ | Platform: linux |
➔ | Process Port: 3000 |
➔ | Site URL: http://0.0.0.0:3000/ |
➔ | ReplicaSet OpLog: Enabled |
➔ | Commit Hash: 7475d7628a |
➔ | Commit Branch: HEAD |
➔ | |
➔ +---------------------------------------------+
Exit from the rocketchat user process. by typing exit (maybe twice). This should bring you to your account profile.
After that, run the commands below to create Rocket.Chat service.
sudo nano /etc/systemd/system/rocketchat.service
Then copy and paste the lines below into the file and save.
[Unit]
Description=Rocket.Chat server
After=network.target nss-lookup.target mongod.target
[Service]
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=rocketchat
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat MONGO_OPLOG_URL=mongodb://localhost:27017/local?replSet=rs01 ROOT_URL=http://example.com PORT=3000
ExecStart=/usr/local/bin/node /opt/rocketchat/Rocket.Chat/main.js
[Install]
WantedBy=multi-user.target
Save the file and exit.
Next, enable the rocketchat services we just created above.
sudo systemctl daemon-reload sudo systemctl enable rocketchat sudo systemctl start rocketchat
Check the status of Rocket.Chat by running the commands below:
sudo systemctl status rocketchat
You should see similar lines below:
● rocketchat.service - Rocket.Chat server
Loaded: loaded (/etc/systemd/system/rocketchat.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-07-05 13:09:07 CDT; 21s ago
Main PID: 4077 (node)
Tasks: 10 (limit: 4915)
CGroup: /system.slice/rocketchat.service
└─4077 /usr/local/bin/node /opt/rocketchat/Rocket.Chat/main.js
Jul 05 13:09:26 ubuntu1804 rocketchat[4077]: ➔ | MongoDB Version: 4.0.10 |
Jul 05 13:09:26 ubuntu1804 rocketchat[4077]: ➔ | MongoDB Engine: wiredTiger |
Jul 05 13:09:26 ubuntu1804 rocketchat[4077]: ➔ | Platform: linux |
Jul 05 13:09:26 ubuntu1804 rocketchat[4077]: ➔ | Process Port: 3000
Jul 05 13:09:26 ubuntu1804 rocketchat[4077]: ➔ +---------------------------------------------+
Now everything is installed and configured.
Open your browser and browse to the server name followed by port 3000
http://example.com:3000
The installation wizard will guide you through setting up your first administrative user, configuring your organization, registering your server to receive free push notifications, and more.

Next, type in your organization info and continue

After that, provide your server info

Then, Register your server.

Next,

That’s it!

Congratulations! You have successfully installed and configured Rocket. Chat server on Ubuntu 16.04 | 18.04 LTS
You may also like the post below:
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!