2225 words
11 minutes

Install Rocket.Chat on Ubuntu Server

Cover image for Install Rocket.Chat on Ubuntu Server

This article is for those looking for a detailed and straightforward guide on installing Rocket.Chat on Ubuntu Server.

Rocket.Chat is an open-source fully customizable communications platform developed in JavaScript for organizations with high standards of data protection.

IMPORTANT

OpenSSH must be installed on the server, and port 22 must be open in order to be able to connect to the server using the SSH protocol.

To install OpenSSH on a server, you can use the command:

Terminal window
sudo apt install openssh-server
NOTE

To connect to the server from a Windows system, you can use tools like PuTTY or MobaXterm.

NOTE

This guide walks you through connecting to a server with the iTerm2 terminal emulator on macOS.

CAUTION

You will need to open the following TCP ports for access to the services:

  • TCP port 80 - to receive a free cryptographic certificate through the Let’s Encrypt CA.
  • TCP port 443 - to access the Rocket.Chat web interface.

We connect to the server on which you plan to install Rocket.Chat.

NOTE

To obtain and subsequently renew a free SSL certificate, we will use the Let’s Encrypt certification authority, as well as the Certbot software client, which is designed to make it as easy as possible to obtain and renew a certificate through the Let’s Encrypt certification authority.

NOTE

This tutorial will use MongoDB as the database management system and Nginx as the webserver.

To install MongoDB, you need to import the MongoDB public key and add a new repository.

Import the MongoDB public key using the command:

Terminal window
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -

Install Rocket.Chat on Ubuntu Server - Step 1

Let’s add the MongoDB repository using the command:

Terminal window
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

Install Rocket.Chat on Ubuntu Server - Step 2

Update the local package index to the latest changes in the repositories using the command:

Terminal window
sudo apt update

Install Rocket.Chat on Ubuntu Server - Step 3

Let’s make it possible to install Node.js through the package manager using the command:

Terminal window
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -

Install Rocket.Chat on Ubuntu Server - Step 4

Now let’s install the packages necessary for Rocket.Chat to work using the command:

Terminal window
sudo apt install -y nginx certbot python3-certbot-nginx nodejs build-essential mongodb-org graphicsmagick
NOTE

This tutorial will use MongoDB as the database management system and Nginx as the web server.

Install Rocket.Chat on Ubuntu Server - Step 5

For Rocket.Chat to work correctly, it is recommended to use Node.js version 14.18.3.

Let’s install a tool called “n” so that we can change the version of Node.js with the command:

Terminal window
sudo npm install -g inherits n

Install Rocket.Chat on Ubuntu Server - Step 6

Next, install Node.js version 14.18.3 using the command:

Terminal window
sudo n 14.18.3

Install Rocket.Chat on Ubuntu Server - Step 7

Now, in order to increase the security level of the webserver, it is necessary to obtain a cryptographic certificate for the domain or subdomain, through which the Multicraft control panel will be accessible from the Internet.

NOTE

To obtain and subsequently renew a free SSL certificate, we will use the Let’s Encrypt certification authority, as well as the Certbot software client, which is designed to make it as easy as possible to obtain and renew a certificate through the Let’s Encrypt certification authority.

NOTE

In this tutorial, the rocketchat.heyvaldemar.net subdomain will be used to access Rocket.Chat from the Internet. You will need to specify your domain or subdomain by which your Rocket.Chat will be available from the Internet.

Request a cryptographic certificate using the command:

Terminal window
sudo certbot --nginx -d rocketchat.heyvaldemar.net

Install Rocket.Chat on Ubuntu Server - Step 8

Next, specify the email address to which Let’s Encrypt will send notifications about the expiration of the cryptographic certificate and press the “Enter” button.

Install Rocket.Chat on Ubuntu Server - Step 9

The next step is to read and accept the terms of use of the services provided.

Press the “a” button, then “Enter” if you agree with the terms of use of the services provided.

Install Rocket.Chat on Ubuntu Server - Step 10

The next step is to choose whether you want to share the email address you provided earlier with the Electronic Frontier Foundation to receive newsletters.

Press the “n” button, then “Enter”.

Install Rocket.Chat on Ubuntu Server - Step 11

The next step is to choose whether you want the Nginx configuration file to have parameters automatically added to automatically redirect HTTP traffic to HTTPS.

Press the “1” button, then “Enter”.

Install Rocket.Chat on Ubuntu Server - Step 12

NOTE

Cryptographic certificates obtained through the Let’s Encrypt Certificate Authority are valid for ninety days. Certbot automatically adds a certificate renewal script to the task scheduler and the script runs twice a day, automatically renewing any cryptographic certificate that expires within thirty days.

You can check the operability of the cryptographic certificate renewal process using the command:

Terminal window
sudo certbot renew --dry-run

Install Rocket.Chat on Ubuntu Server - Step 13

Now let’s configure Nginx for subsequent work with Rocket.Chat.

First, you need to make changes to the Nginx configuration file by opening it in a text editor using the command:

Terminal window
sudo vim /etc/nginx/nginx.conf

Install Rocket.Chat on Ubuntu Server - Step 14

Hit the “i” button to go into edit mode, find the parameter “server_names_hash_bucket_size 64;” and uncomment it by removing the ”#” symbol.

Install Rocket.Chat on Ubuntu Server - Step 15

Now press the “Esc” button to exit edit mode, then type "" and press the “Enter” button to save your changes and exit the editor.

Install Rocket.Chat on Ubuntu Server - Step 16

Now you need to create a block (called virtual hosts in Apache), with which Rocket.Chat will work in the future.

Let’s create a virtual host file using a text editor using the command:

Terminal window
sudo vim /etc/nginx/sites-available/rocketchat.heyvaldemar.net
NOTE

In this tutorial, the rocketchat.heyvaldemar.net subdomain will be used to access Rocket.Chat from the Internet. You will need to specify your domain or subdomain by which your Rocket.Chat will be available from the Internet.

Install Rocket.Chat on Ubuntu Server - Step 17

Hit the “i” button to go into edit mode, then insert the following configuration for the webserver to work.

NOTE

In this tutorial, the rocketchat.heyvaldemar.net subdomain will be used to access Rocket.Chat from the Internet. You will need to specify your domain or subdomain by which your Rocket.Chat will be available from the Internet.

Install Rocket.Chat on Ubuntu Server - Step 18

Now press the “Esc” button to exit edit mode, then type "" and press the “Enter” button to save your changes and exit the editor.

Install Rocket.Chat on Ubuntu Server - Step 19

Activate the created block using the command:

Terminal window
sudo ln -s /etc/nginx/sites-available/rocketchat.heyvaldemar.net /etc/nginx/sites-enabled/

Install Rocket.Chat on Ubuntu Server - Step 20

Deactivate the block created by default using the command:

Terminal window
sudo unlink /etc/nginx/sites-enabled/default

Install Rocket.Chat on Ubuntu Server - Step 21

Verify that there are no errors in the syntax of the new Nginx configuration file using the command:

Terminal window
sudo nginx -t

Install Rocket.Chat on Ubuntu Server - Step 22

Restart Nginx to apply the changes, using the command:

Terminal window
sudo systemctl restart nginx

Install Rocket.Chat on Ubuntu Server - Step 23

Verify that Nginx has successfully started using the command:

Terminal window
sudo systemctl status nginx

Install Rocket.Chat on Ubuntu Server - Step 24

Now let’s download the archive “rocket.chat.tgz” containing the files for installing Rocket.Chat using the command:

Terminal window
curl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz

Install Rocket.Chat on Ubuntu Server - Step 25

Unpack the downloaded archive “rocket.chat.tgz” using the command:

Terminal window
tar -xzf /tmp/rocket.chat.tgz -C /tmp

Install Rocket.Chat on Ubuntu Server - Step 26

Let’s delete the previously downloaded “rocket.chat.tgz” archive containing the files for installing Rocket.Chat using the command:

Terminal window
rm -f /tmp/rocket.chat.tgz

Install Rocket.Chat on Ubuntu Server - Step 27

Let’s go to the “server” folder using the command:

Terminal window
cd /tmp/bundle/programs/server

Install Rocket.Chat on Ubuntu Server - Step 28

Now let’s start the installation of Rocket.Chat using the command:

Terminal window
npm install

Install Rocket.Chat on Ubuntu Server - Step 29

Rename the “bundle” folder to “Rocket.Chat” using the command:

Terminal window
sudo mv /tmp/bundle /opt/Rocket.Chat

Install Rocket.Chat on Ubuntu Server - Step 30

Now let’s create the “rocket” user, which will be used to launch Rocket.Chat, with the command:

Terminal window
sudo useradd -M rocketchat

Install Rocket.Chat on Ubuntu Server - Step 31

Block the user with the command:

Terminal window
sudo usermod -L rocketchat

Install Rocket.Chat on Ubuntu Server - Step 32

Assign the correct rights to the “/opt/Rocket.Chat” directory using the command:

Terminal window
sudo chown -R rocketchat:rocketchat /opt/Rocket.Chat

Install Rocket.Chat on Ubuntu Server - Step 33

Next, you need to configure the autostart of the Rocket.Chat service when the operating system starts.

Let’s create a unit that will contain the necessary configuration for the Rocket.Chat service in the “/etc/systemd/system/” directory using the command:

Terminal window
sudo vim /lib/systemd/system/rocketchat.service

Install Rocket.Chat on Ubuntu Server - Step 34

Hit the “i” button to go into edit mode, then insert the following configuration for the webserver to work.

NOTE

In this tutorial, the rocketchat.heyvaldemar.net subdomain will be used to access Rocket.Chat from the Internet. You will need to specify your domain or subdomain by which your Rocket.Chat will be available from the Internet.

Install Rocket.Chat on Ubuntu Server - Step 35

Now press the “Esc” button to exit edit mode, then type "" and press the “Enter” button to save your changes and exit the editor.

Install Rocket.Chat on Ubuntu Server - Step 36

Now let’s make changes to the MongoDB configuration using the command:

Terminal window
sudo sed -i "s/^# engine:/ engine: mmapv1/" /etc/mongod.conf

Install Rocket.Chat on Ubuntu Server - Step 37

Next, let’s make one more change to the MongoDB configuration using the command:

Terminal window
sudo sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf

Install Rocket.Chat on Ubuntu Server - Step 38

We enable autostart of the MongoDB service at operating system startup using the command:

Terminal window
sudo systemctl enable mongod

Install Rocket.Chat on Ubuntu Server - Step 39

Start MongoDB with the command:

Terminal window
sudo systemctl start mongod

Install Rocket.Chat on Ubuntu Server - Step 40

Check that MongoDB started successfully with the command:

Terminal window
sudo systemctl status mongod

Install Rocket.Chat on Ubuntu Server - Step 41

Let’s check that MongoDB is working correctly with the command:

Terminal window
mongo --eval "printjson(rs.initiate())"

Install Rocket.Chat on Ubuntu Server - Step 42

We enable autostart of the Rocket.Chat service when the operating system starts using the command:

Terminal window
sudo systemctl enable rocketchat

Install Rocket.Chat on Ubuntu Server - Step 43

Launch Rocket.Chat with the command:

Terminal window
sudo systemctl start rocketchat

Install Rocket.Chat on Ubuntu Server - Step 44

Let’s check that Rocket.Chat has successfully launched using the command:

Terminal window
sudo systemctl status rocketchat

Install Rocket.Chat on Ubuntu Server - Step 45

All necessary services have been successfully launched.

Install Rocket.Chat on Ubuntu Server - Step 46

To access the Rocket.Chat management panel, go to https://rocketchat.heyvaldemar.net from your workstation, where rocketchat.heyvaldemar.net is the domain name of my service. Accordingly, you need to specify your domain name that points to the IP address of your server with the installed Rocket.Chat service.

Next, we need to create a new user who will have administrator rights in Rocket.Chat.

In the “Full name” field, enter the first and last name for the new Rocket.Chat user.

In the “Username” field, specify a login for the new Rocket.Chat user.

In the “Email” field, provide a current email address for the new Rocket.Chat user.

In the “Password” field, set a secure password for the new Rocket.Chat user.

Click the “Next” button.

Install Rocket.Chat on Ubuntu Server - Step 47

Now, you need to fill in the information about your organization.

In the “Organization name” field, enter the name of your organization.

In the “Organization industry” field, specify the profile or sector of your organization.

In the “Organization size” field, indicate the number of employees in your organization.

In the “Country” field, specify the country where your organization operates.

Click the “Next” button.

Install Rocket.Chat on Ubuntu Server - Step 48

Now, you need to register your server to utilize services such as mobile push notifications, integration with external providers, and more.

In the “Cloud account email” field, provide a current email address.

Next, you should read and accept the terms of use for the provided services.

Click the “Register” button.

Install Rocket.Chat on Ubuntu Server - Step 49

You will receive an email at the address provided earlier with a link to register your Rocket.Chat server.

Install Rocket.Chat on Ubuntu Server - Step 50

Find the email and click on the “Verify registration” button.

Install Rocket.Chat on Ubuntu Server - Step 51

Your server has been successfully registered.

Install Rocket.Chat on Ubuntu Server - Step 52

Welcome to the Rocket.Chat control panel.

Install Rocket.Chat on Ubuntu Server - Step 53


Patreon Exclusives#

🏆 Join my Patreon and dive deep into the world of Docker and DevOps with exclusive content tailored for IT enthusiasts and professionals. As your experienced guide, I offer a range of membership tiers designed to suit everyone from newbies to IT experts.


Tools I Personally Trust#

If you’re building things, breaking things, and trying to keep your digital life a little saner (like every good DevOps engineer), these are two tools that I trust and use daily:

🛸 Proton VPN - My shield on the internet. It keeps your Wi-Fi secure, hides your IP, and blocks those creepy trackers. Even if I’m hacking away on free café Wi-Fi, I know I’m safe.

🔑 Proton Pass - My password vault. Proper on-device encryption, 2FA codes, logins, secrets - all mine and only mine. No compromises.

These are partner links - you won’t pay a cent more, but you’ll be supporting DevOps Compass. Thanks a ton - it helps me keep this compass pointing the right way 💜


Gear & Books I Trust#

📕 Essential DevOps books
🖥️ Studio streaming & recording kit
📡 Streaming starter kit


Social Channels#

🎬 YouTube
🐦 X (Twitter)
🎨 Instagram
🐘 Mastodon
🧵 Threads
🎸 Facebook
🦋 Bluesky
🎥 TikTok
💻 LinkedIn
📣 daily.dev Squad
✈️ Telegram
🐈 GitHub


Community of IT Experts#

👾 Discord


Refill My Coffee Supplies#

💖 PayPal
🏆 Patreon
🥤 BuyMeaCoffee
🍪 Ko-fi
💎 GitHub
Telegram Boost

🌟 Bitcoin (BTC): bc1q2fq0k2lvdythdrj4ep20metjwnjuf7wccpckxc
🔹 Ethereum (ETH): 0x76C936F9366Fad39769CA5285b0Af1d975adacB8
🪙 Binance Coin (BNB): bnb1xnn6gg63lr2dgufngfr0lkq39kz8qltjt2v2g6
💠 Litecoin (LTC): LMGrhx8Jsx73h1pWY9FE8GB46nBytjvz8g


Is this content AI-generated?

No. Every article on this blog is written by me personally, drawing on decades of hands-on IT experience and a genuine passion for technology.

I use AI tools exclusively to help polish grammar and ensure my technical guidance is as clear as possible. However, the core ideas, strategic insights, and step-by-step solutions are entirely my own, born from real-world work.

Because of this human-and-AI partnership, some detection tools might flag this content. You can be confident, though, that the expertise is authentic. My goal is to share road-tested knowledge you can trust.

Install Rocket.Chat on Ubuntu Server
https://www.heyvaldemar.com/install-rocket-chat-on-ubuntu-server/
Author
Vladimir Mikhalev
Published at
2022-04-13
License
CC BY-NC-SA 4.0