Installing Rocket.Chat on Ubuntu Server | Information Technology from Valdemar

This article is written for those who were searching for a detailed and simple for the understanding 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 much more. Rocket.Chat can be installed on your own server, and then communicate using the web interface, a personal computer, or a mobile device.

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

You can read more about how to install Ubuntu Server 18.04 LTS in my guide «Installing Ubuntu Server 18.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 the server, you can use the command:

sudo apt-get install openssh-server

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

This guide covers connecting 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 certificate authority.
  • 443 – to access the Rocket.Chat web interface.

Connect to the server on which it is planned to install Rocket.Chat.

Next, you must confirm that we trust the server to which we are connecting.

Enter “yes” and press the “Enter” button.

To obtain and subsequently renew a free SSL certificate, we will use the Let’s Encrypt Certificate Authority, as well as the Certbot software client, which is designed to simplify the receipt and renewal of the certificate through the Let’s Encrypt Certificate Authority.

Add the Certbot repository using the command:

sudo add-apt-repository ppa:certbot/certbot

Press the “Enter” button to confirm the addition of a new repository.

Please note that in this guide MongoDB will be used as the database management system, and Nginx will be used as the webserver.

To install MongoDB, you need to import the GPG MongoDB public key from “https://www.mongodb.org/static/pgp/server-4.2.asc” and add a new repository.

Import the GPG MongoDB public key from “https://www.mongodb.org/static/pgp/server-4.2.asc” using the command:

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

Add the MongoDB repository using the command:

sudo echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list

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

sudo apt-get update

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

sudo apt install -y nginx certbot python-certbot-nginx gnupg curl nodejs npm build-essential mongodb-org graphicsmagick

Please note that in this guide MongoDB will be used as the database management system, and Nginx will be used as the webserver.

For the correct operation of Rocket.Chat, it is recommended to use Node.js version 8.11.4.

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

sudo npm install -g inherits n

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

sudo n 8.11.4

Now, to increase the security level of the webserver, it is necessary 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 Certificate Authority, as well as the Certbot software client, which is designed to simplify the receipt and renewal of the certificate through the Let’s Encrypt Certificate Authority.

In this manual, 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.

Request a cryptographic certificate using the command:

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

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

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 to the terms of use of the services provided.

At the next stage, you need to choose: do you want to share the email address indicated above with the Electronic Frontier Foundation to receive newsletters.

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

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

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

Please note that cryptographic certificates obtained through the Let’s Encrypt Certificate Authority are valid for ninety days. Certbot automatically adds a script to renew the certificate in the task scheduler, and the script runs twice a day, automatically updating any cryptographic certificate that expires in thirty days.

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

sudo certbot renew --dry-run

Now 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

Press the “i” button to enter the editing mode, find the parameter “server_names_hash_bucket_size 64;” and uncomment it by removing the “#” sign.

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

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

Create a virtual host file using a text editor using the command:

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

In this manual, 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 accessible from the Internet.

Press the “i” button to enter the editing mode, then insert the following configuration for the webserver to work:

In this manual, 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 accessible from the Internet.

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

Activate the created block using the command:

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

Deactivate the default block using the command:

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

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

sudo nginx -t

Restart Nginx to apply the changes using the command:

sudo systemctl restart nginx

Verify that Nginx started successfully using the command:

sudo systemctl status nginx

Now create the user “rocket”, which will be used to launch Rocket.Chat, using the command:

sudo useradd -m -U -r -d /opt/rocket rocket

Next, add a new user to the “www-data” group using the command:

sudo usermod -a -G rocket www-data

Assign the correct permissions to the “/opt/rocket” directory using the command:

sudo chmod 750 /opt/rocket

Now switch to the previously created user “rocket” using the command:

sudo su - rocket

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 rocket.chat.tgz

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

tar -xzf rocket.chat.tgz

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

rm -f rocket.chat.tgz

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

mv bundle Rocket.Chat

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

cd Rocket.Chat/programs/server

Now start the installation of Rocket.Chat using the command:

npm install

Exit from the user “rocket” with the command:

exit

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

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

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

Press the “i” button to enter the editing mode, then insert the following configuration:

In this manual, 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 accessible from the Internet.

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

Restart “systemd” to search for changed or new units using the command:

sudo systemctl daemon-reload

Rocket.Chat uses the MongoDB replica set to improve performance.

Configure the replica set using the command:

sudo echo -e "replication:\n replSetName: \"rs01\"" | sudo tee -a /etc/mongod.conf

Enable autorun of the MongoDB service when the operating system is started using the command:

sudo systemctl enable mongod

Start MongoDB with the command:

sudo systemctl start mongod

Verify that MongoDB started successfully using the command:

sudo systemctl status mongod

Check that MongoDB works correctly using the command:

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

Enable the autorun of the Rocket.Chat service when the operating system is launched using the command:

sudo systemctl enable rocketchat

Run Rocket.Chat with the command:

sudo systemctl start rocketchat

Check that Rocket.Chat successfully started using the command:

sudo systemctl status rocketchat

All necessary services have been successfully launched.

Now you need to wait a few minutes, then to continue the process of installing the Rocket.Chat, you must go from workstation to the link https://rocketchat.heyvaldemar.net, where rocketchat.heyvaldemar.net is the name of my server. Accordingly, you need to specify 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 user Rocket.Chat.

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

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

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

Click on the “Continue” button.

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

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

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

In the “Industry” field specify the profile of your organization.

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

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

In the “Website” field specify the address of the website of your organization.

Click on the “Continue” button.

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

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

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

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

Click on the “Continue” button.

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

Click on the “Continue” button.

Rocket.Chat installation completed successfully.

Click on the “Go to your workspace” button.

Welcome to Rocket.Chat.

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

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

Click on the button “Click here to finish registering your workspace”.

Specify the username and password from the previously created account and click on the “Login” button.

The server is successfully registered.

Now you need to create a new account at https://cloud.rocket.chat for more options to manage your Rocket.Chat workspace.

An email containing a link to register a new account at https://cloud.rocket.chat will be sent to the email address specified when creating the new account created earlier.

In the window that opens, you need to specify a strong password twice to create a new account at https://cloud.rocket.chat.

In the “Workspaces” section, you will see your registered Rocket.Chat server.

Links for downloading the Rocket.Chat client can be found on the official website https://rocket.chat/install.

Author

Hi, 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. On my website, you will find detailed and clear guides for setting up IT solutions. Dive into the ocean, full of positive and technology! For cooperation: callvaldemar@gmail.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.