This article is for those looking for a detailed and clear guide on how to install Rocket.Chat on Ubuntu Server.

Rocket.Chat is an open-source messenger that supports group chats, file sharing, video conferencing, bots, and more. Rocket.Chat can be installed on your own server and then communicate using the web interface, personal computer, or mobile device.

In this guide, we will consider the case when you already have a server with the Ubuntu Server 20.04 LTS operating system installed on it.

You can read more about how to install Ubuntu Server 20.04 LTS in my guide “Install Ubuntu Server 20.04 LTS”.

In addition, 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:

sudo apt install openssh-server

If you plan to connect to the server using the Windows operating system, you can use PuTTY, a free client for various remote access protocols, including SSH, Telnet, rlogin.

This guide describes how to connect to a server using the iTerm2 terminal emulator installed on the macOS operating system.

Please note that you will need to open the following TCP ports to access your server:

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

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

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.

Please note that 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 GPG key and add a new repository.

Import the MongoDB public GPG key using the command:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

Install Rocket.Chat on Ubuntu Server

Add MongoDB repository using the command:

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

Install Rocket.Chat on Ubuntu Server

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

sudo apt update

Install Rocket.Chat on Ubuntu Server

Let’s provide the ability to install Node.js through the package manager using the command:

curl -sL https://deb.nodesource.com/setup_12.x | sudo bash -

Install Rocket.Chat on Ubuntu Server

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

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

Please note that this tutorial will use MongoDB as the database management system and Nginx as the webserver.

Install Rocket.Chat on Ubuntu Server

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

Install a tool called “n” so that we can change the Node.js version using the command:

sudo npm install -g inherits n

Install Rocket.Chat on Ubuntu Server

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

sudo n 12.14.0

Install Rocket.Chat on Ubuntu Server

Now, in order to increase the security level of the webserver, you need to obtain a cryptographic certificate for the domain or subdomain, through which the Rocket.Chat control panel will be accessible from the Internet.

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.

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

Let’s request a cryptographic certificate using the command:

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

Install Rocket.Chat on Ubuntu Server

Next, we 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

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

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

Install Rocket.Chat on Ubuntu Server

The next step is to choose: do you want to share the above email address with the Electronic Frontier Foundation in order to receive newsletters.

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

Install Rocket.Chat on Ubuntu Server

At the next step, you need to choose: do you want the parameters to be automatically added to the Nginx configuration file for automatically redirecting HTTP traffic to HTTPS.

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

Install Rocket.Chat on Ubuntu Server

Please note that cryptographic certificates obtained through Let’s Encrypt CA are valid for ninety days. Certbot automatically adds a script to renew the certificate 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 functionality of the cryptographic certificate renewal process using the command:

sudo certbot renew --dry-run

Install Rocket.Chat on Ubuntu Server

Now let’s configure Nginx for further 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:

sudo vim /etc/nginx/nginx.conf

Install Rocket.Chat on Ubuntu Server

Click on 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

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

Install Rocket.Chat on Ubuntu Server

Now you need to create a block (called a virtual host 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:

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

In this guide, you will use the rocketchat.heyvaldemar.net subdomain to access Rocket.Chat from the Internet. You will need to specify your domain or subdomain by which your Rocket.Chat will be accessible from the Internet.

Install Rocket.Chat on Ubuntu Server

Click on the “i” button to go into edit mode, then insert the configuration.

In this guide, you will use the rocketchat.heyvaldemar.net subdomain to access Rocket.Chat from the Internet. You will need to specify your domain or subdomain by which your Rocket.Chat will be accessible from the Internet.

Install Rocket.Chat on Ubuntu Server

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

Install Rocket.Chat on Ubuntu Server

We activate the created block using the command:

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

Install Rocket.Chat on Ubuntu Server

We deactivate the block created by default using the command:

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

Install Rocket.Chat on Ubuntu Server

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

sudo nginx -t

Install Rocket.Chat on Ubuntu Server

Restart Nginx to apply the changes made using the command:

sudo systemctl restart nginx

Install Rocket.Chat on Ubuntu Server

Check that Nginx has started successfully using the command:

sudo systemctl status nginx

Install Rocket.Chat on Ubuntu Server

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

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

Install Rocket.Chat on Ubuntu Server

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

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

Install Rocket.Chat on Ubuntu Server

Delete the previously downloaded “rocket.chat.tgz” archive containing the files for installing Rocket.Chat using the command:

rm -f /tmp/rocket.chat.tgz

Install Rocket.Chat on Ubuntu Server

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

cd /tmp/bundle/programs/server

Install Rocket.Chat on Ubuntu Server

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

npm install

Install Rocket.Chat on Ubuntu Server

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

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

Install Rocket.Chat on Ubuntu Server

Now let’s create a user “rocket” that will be used to launch Rocket.Chat using the command:

sudo useradd -M rocketchat

Install Rocket.Chat on Ubuntu Server

Let’s block the user using the command:

sudo usermod -L rocketchat

Install Rocket.Chat on Ubuntu Server

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

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

Install Rocket.Chat on Ubuntu Server

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:

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

Install Rocket.Chat on Ubuntu Server

Click on the “i” button to go into edit mode, then insert the configuration.

In this guide, you will use the rocketchat.heyvaldemar.net subdomain to access Rocket.Chat from the Internet. You will need to specify your domain or subdomain by which your Rocket.Chat will be accessible from the Internet.

Install Rocket.Chat on Ubuntu Server

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

Install Rocket.Chat on Ubuntu Server

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

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

Install Rocket.Chat on Ubuntu Server

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

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

Install Rocket.Chat on Ubuntu Server

We enable autostart of the MongoDB service when starting the operating system using the command:

sudo systemctl enable mongod

Install Rocket.Chat on Ubuntu Server

Launch MongoDB using the command:

sudo systemctl start mongod

Install Rocket.Chat on Ubuntu Server

Let’s check that MongoDB has started successfully using the command:

sudo systemctl status mongod

Install Rocket.Chat on Ubuntu Server

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

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

Install Rocket.Chat on Ubuntu Server

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

sudo systemctl enable rocketchat

Install Rocket.Chat on Ubuntu Server

Launch Rocket.Chat using the command:

sudo systemctl start rocketchat

Install Rocket.Chat on Ubuntu Server

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

sudo systemctl status rocketchat

Install Rocket.Chat on Ubuntu Server

All necessary services have been successfully launched.

Install Rocket.Chat on Ubuntu Server

Now you need to wait a few minutes, then to continue the Rocket.Chat installation process, you need to go from the workstation to the link https://rocketchat.heyvaldemar.net, where rocketchat.heyvaldemar.net is the name of my server. Accordingly, you need to provide the name or IP address of your server with Rocket.Chat installed.

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

In the “Name” field, specify the name for the new Rocket.Chat user.

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

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

In the “Password” field, specify a strong password for the new Rocket.Chat user.

Click on the “Continue” button.

Install Rocket.Chat on Ubuntu Server

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

In the “Organization Type” field, indicate the type of your organization.

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

In the field “Industry” we indicate the profile of your organization.

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

In the “Country” field, indicate the country in which your organization operates.

In the “Website” field, indicate the address of your organization’s website.

Click on the “Continue” button.

Install Rocket.Chat on Ubuntu Server

Next, you need to fill in the information about your Rocket.Chat server.

In the “Site Name” field, specify the desired name of the Rocket.Chat site.

In the “Language” field, specify the language for your Rocket.Chat server.

In the “Server Type” field, indicate whether your Rocket.Chat server will be public or private.

In the “Auto opt in new users for Two Factor via Email” field, indicate two-factor authentication will be enabled for Rocket.Chat users

Click on the “Continue” button.

Install Rocket.Chat on Ubuntu Server

We select “Register to access” to use services such as mobile push notifications and others from Rocket.Chat Technologies Corp.

Click on the “Continue” button.

Install Rocket.Chat on Ubuntu Server

Rocket.Chat installation completed successfully.

Click on the “Go to your workspace” button.

Install Rocket.Chat on Ubuntu Server

Welcome to Rocket.Chat.

Install Rocket.Chat on Ubuntu Server

Now you need to register your server to use services such as mobile push notifications and others from Rocket.Chat Technologies Corp.

An email with a link for registering your Rocket.Chat server will be sent to the email address specified when creating a new account (created earlier).

Click on the button “Login or Create an Account to get started!”.

Install Rocket.Chat on Ubuntu Server

If you do not already have an account on the Rocket.Chat website, please register by clicking on the “Register now” button for more options to manage your Rocket.Chat workspace.

If you already have an account on the Rocket.Chat website, then in the “E-mail Address” field, enter the email address associated with the Rocket.Chat Cloud account.

Then we specify the password for the account and click on the “Log in” button.

Install Rocket.Chat on Ubuntu Server

In the “Workspaces” section, click on the “Register self-managed” button.

Install Rocket.Chat on Ubuntu Server

Next, you need to choose: is your server connected to the Internet.

This tutorial is about a Rocket.Chat server connected to the Internet.

Select “Internet access” and click on the “Continue” button.

Install Rocket.Chat on Ubuntu Server

Save the received registration code and click on the “Close” button.

Install Rocket.Chat on Ubuntu Server

We return to the Rocket.Chat control panel.

Click on the icon with the image of three dots in the upper left corner of the screen and select “Administration”.

Install Rocket.Chat on Ubuntu Server

Go to the “Connectivity Services” section, specify the previously received registration code in the “Token” field and click on the “Connect” button.

Install Rocket.Chat on Ubuntu Server

Server registered successfully.

Now you need to log in with your Rocket.Chat Cloud account to access the app store and other Rocket.Chat services.

Click on the “Login to Rocket.Chat Cloud” button.

Install Rocket.Chat on Ubuntu Server

In the “E-mail Address” field, specify the email address associated with the Rocket.Chat Cloud account.

Then we specify the password for the account and click on the “Log in” button.

Install Rocket.Chat on Ubuntu Server

Next, click on the “Authorization” button.

Install Rocket.Chat on Ubuntu Server

Specify the username and password of an account with administrator rights on your Rocket.Chat server, and click on the “Login” button.

Install Rocket.Chat on Ubuntu Server

Login with Rocket.Chat Cloud account successfully completed.

Install Rocket.Chat on Ubuntu Server

Also under the “Workspaces” section of the Rocket.Chat website, you will see your registered Rocket.Chat server.

Install Rocket.Chat on Ubuntu Server

You can find links to download the Rocket.Chat client on the official Rocket.Chat website.

Vladimir Mikhalev
hey, I’m Vladimir Mikhalev, but my friends call me Valdemar. I have a lot of experience in the design and maintenance of various information systems.

Recent Posts