How to Install Rocket.Chat on Ubuntu 20.04

Choose a different version or distribution

Introduction

Before we begin talking about how to install Rocket.Chat on Ubuntu 20.04 OS, let’s briefly understand – What is Rocket.Chat?

Rocket.Chat is a powerful and versatile open-source communication platform that enables teams to collaborate effectively. It offers features like real-time messaging, video conferencing, file sharing, and integrations with popular tools.

With its user-friendly interface and extensive customization options, Rocket.Chat enhances productivity and facilitates seamless communication across organizations. Whether for remote teams, businesses, or communities, Rocket.Chat serves as a secure and scalable solution for efficient collaboration.

In this tutorial, you will install the latest version of Rocket.Chat. Also, we will address a few FAQs on how to install Rocket.Chat on Ubuntu 20.04.

Advantages of Rocket.Chat

  1. Real-time communication: Rocket.Chat enables instant messaging and live chat, ensuring quick and efficient collaboration.
  2. Versatile features: With video conferencing, file sharing, and integrations, Rocket.Chat offers a comprehensive suite of tools for productive teamwork.
  3. Open-source flexibility: Being open-source, Rocket.Chat allows customization and integration with existing systems, adapting to unique organizational needs.
  4. Secure and private: Rocket.Chat prioritizes data privacy and provides end-to-end encryption, ensuring confidential communication within teams.
  5. Scalable solution: From small teams to large organizations, Rocket.Chat accommodates growth and delivers a scalable platform for seamless collaboration.

Prerequisites to Install Rocket.Chat on Ubuntu 20.04

  • Ubuntu 20.04 (or) 22.04 64-bit operating system
  • A user account with sudo privileges
  • Command-line/terminal

Step 1 – Install Required Dependency Packages

1) First, install the official MongoDB packages with the following repository file by updating and configuring the package list and apt.

sudo apt-get -y update

Install essential packages:

sudo apt install gnupg2 gnupg git unzip build-essential curl software-properties-common graphicsmagick gcc g++ make net-tools -y
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list

2) After that, use the package manager to install Node.js.

sudo apt update && sudo apt install -y curl && curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -

3) Now, it's time to install build tools, MongoDB, and Nodejs:

sudo apt-get install -y mongodb-org nodejs

*In case you got the following error while installing the MongoDB-org package:

Output
The following packages have unmet dependencies:
 mongodb-org-mongos : Depends: libssl1.1 (>= 1.1.1) but it is not installable
 mongodb-org-server : Depends: libssl1.1 (>= 1.1.1) but it is not installable
 mongodb-org-shell : Depends: libssl1.1 (>= 1.1.1) but it is not installable
E: Unable to correct problems, you have held broken packages.

Fix that using the following commands.

echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee /etc/apt/sources.list.d/focal-security.list

sudo apt-get update
sudo apt-get install libssl1.1

After this, again run the MongoDB installation command.

sudo apt install mongodb-org -y
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-database hold" | sudo dpkg --set-selections
echo "mongodb-org hold" | sudo dpkg --set-selections

Start the MongoDB service

sudo systemctl enable --now mongod
sudo systemctl status mongod

4) Meanwhile, this step is only for Ubuntu 19.04 users.

sudo apt-get install -y npm

5) Finally, it's time to install inherits and n, and the node version required by Rocket.Chat using npm.

sudo npm install -g inherits n && sudo n 14.18.3 && hash -r

Step 2 – Install Rocket Chat

1) Firstly, download the latest Rocket.Chat version.

curl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz
tar -xzf /tmp/rocket.chat.tgz -C /tmp

2) Now, it's time to install.

cd /tmp/bundle/programs/server && npm install
sudo mv /tmp/bundle /opt/Rocket.Chat

Step 3 – Configure Rocket.Chat Service

1) Create the Rocket.Chat service file after adding the Rocket.Chat user and then give the correct permissions to the Rocket Chat folder.

1) Create a new Rocket.Chat user and then give the necessary permissions to the Rocket.Chat folder. Now, you need to create a service file for Rocket.Chat.

sudo useradd -M rocketchat && sudo usermod -L rocketchat
sudo chown -R rocketchat:rocketchat /opt/Rocket.Chat
cat << EOF |sudo tee -a /lib/systemd/system/rocketchat.service
[Unit]
Description=The Rocket.Chat server
After=network.target remote-fs.target nss-lookup.target nginx.service mongod.service
[Service]
ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=rocketchat
Environment=ROOT_URL=http://IP_SERVER-or_FQDN:3000
Environment=PORT=3000
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01
Environment=MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01
[Install]
WantedBy=multi-user.target
EOF

Change IP_SERVER-or_FQDN with your server IP or domain name.

2) Finally, activate and start Rocket.Chat by setting up the storage engine and replication for MongoDB (mandatory for versions > 1).

sudo sed -i "s/^#  engine:/  engine: wiredTiger/"  /etc/mongod.conf
sudo sed -i "s/^#replication:/replication:\n  replSetName: rs01/" /etc/mongod.conf
sudo systemctl daemon-reload && sudo systemctl restart mongod
mongo --eval "printjson(rs.initiate())"
sudo systemctl enable rocketchat && sudo systemctl start rocketchat

Step 4 – Optional configurations

Step 5 – Configure your Rocket.Chat server

After that, visit the configured URL http://your-host-name.com:3000. Then you need to create an admin account, and organization, and add the necessary server information.

FAQs to Install Rocket.Chat on Ubuntu 20.04

What are the system requirements for installing Rocket.Chat on Ubuntu 20.04?

You'll need a server with Ubuntu 20.04 LTS, a minimum of 1 GB RAM, and 4 GB of free disk space.

What are the dependencies required for Rocket.Chat on Ubuntu 20.04?

Rocket.Chat requires MongoDB, Node.js, and npm to be installed on your Ubuntu 20.04 system.

How do I install and configure MongoDB for Rocket.Chat on Ubuntu 20.04?

You can install MongoDB by following the official MongoDB installation guide. After installation, configure it to meet Rocket.Chat's requirements.

Can I use a different database instead of MongoDB with Rocket.Chat on Ubuntu 20.04?

No, Rocket.Chat relies on MongoDB as its primary database, and it's recommended to use MongoDB for optimal performance.

Can I set up SSL/TLS encryption for Rocket.Chat on Ubuntu 20.04?

Yes, Rocket.Chat supports SSL/TLS encryption. You can configure a reverse proxy server like Nginx to handle the SSL/TLS termination for Rocket.Chat.

Are there any additional steps required for Rocket.Chat to function properly on Ubuntu 20.04?

After installation and configuration, you may need to open the necessary ports in your firewall, set up DNS records, and configure email settings to ensure Rocket.Chat works smoothly on Ubuntu 20.04.

Can I install Rocket.Chat on other Linux distributions or operating systems?

Yes, Rocket.Chat supports various Linux distributions and operating systems. Refer to the Rocket.Chat documentation for installation instructions specific to your preferred platform.

Conclusion

We hope this detailed tutorial helped you understand how to install Rocket.Chat on your Ubuntu machine. Click here to read more about Rocket.Chat and its functionalities.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them for sure.