How to Install Rocket.Chat on Ubuntu 24.04

Choose a different version or distribution

Introduction

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

Rocket.Chat is an open-source platform designed to streamline communication within organizations. It offers features like chat, video conferencing, file sharing, and more in one application. Users can create channels for different teams, projects, or topics, ensuring organized discussions.

Rocket.Chat supports customization, allowing businesses to tailor it to their specific needs. With its user-friendly interface and collaborative tools, Rocket.Chat enhances productivity and connectivity across teams. This versatile solution is ideal for businesses seeking efficient and secure communication tools.

In this tutorial, you will install Rocket.Chat on Ubuntu 24.04. We will also address a few FAQs on how to install Rocket.Chat on Ubuntu 24.04.

Advantages of Rocket.Chat on Ubuntu 24.04

  1. Open-Source: Rocket.Chat is freely available for customization.
  2. Real-Time Communication: Enables instant messaging, video conferencing, and file sharing.
  3. Channel-Based Communication: Organizes discussions into channels for better team collaboration.
  4. Customization: Tailor the platform to suit your organization's specific requirements.
  5. Security: Ensures secure communication for sensitive information exchange, with end-to-end encryption, access control, and data protection features.

Prerequisites to Install Rocket.Chat on Ubuntu 22.04

  • Ubuntu 24.04 64-bit operating system
  • A user account with sudo privileges
  • Command-line/terminal

Step 1 – Install Required Dependency Packages

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

sudo apt-get 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_18.x | sudo -E bash -

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

sudo apt-get install -y mongodb-org nodejs

In case you got the following error while installing 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 this 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) 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, organization, and add the necessary server information.

FAQs to Install Rocket.Chat

What is the role of Node.js in Rocket.Chat? 

Node.js is the runtime environment that executes the Rocket.Chat server code.

How do I enable and start the Rocket.Chat service? 

Run: sudo systemctl enable --now rocketchat

How do I stop the Rocket.Chat service?

 Use the command: sudo systemctl stop rocketchat

What is the command to restart the Rocket.Chat service? 

Run: sudo systemctl restart rocketchat

How do I check the status of the Rocket.Chat service? 

Use: sudo systemctl status rocketchat

What is the difference between Rocket.Chat and Slack? 

Rocket.Chat is open-source and customizable, while Slack is a proprietary service.

How do I set permissions for the Rocket.Chat directory? 

Execute: sudo chown -R rocketchat:rocketchat /opt/Rocket.Chat

Conclusion

We hope this tutorial helped you understand how to install Rocket.Chat on Ubuntu 24.04.

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