YouTube Icon

Code Playground.

How to Deploy Rocket.Chat on Ubuntu 18.04

CFG

How to Deploy Rocket.Chat on Ubuntu 18.04

Rocket.Chat is an open-source group correspondence stage, a self-facilitated Slack other option. It is created utilizing the Meteor system and gives different highlights including helpdesk talk, record sharing, video conferencing, voice messages, API, and the sky is the limit from there. 

Rocket.Chat is an ideal answer for organizations and networks that need to have their own talk framework. 

In this instructional exercise, we will tell you the best way to send Rocket.Chat on a Ubuntu 18.04 worker and arrange Nginx as a SSL turn around intermediary. 

Prerequisites

Prior to continuing with this instructional exercise, ensure that you have the accompanying requirements. 

  • Ubuntu 18.04 worker. As indicated by the authority Rocket.Chat framework prerequisites you need at any rate 1G of RAM. 
  • An area name highlighting your worker IP address. We will utilize chat.example.com. 
  • Nginx introduced, by following this instructional exercise . 
  • You have a SSL endorsement introduced for your area. You can produce a free Let's Encrypt SSL authentication by following this instructional exercise . 

Installing Node.js

Start by refreshing your framework bundles list: 

sudo apt update

Introduce Node.js, npm and any remaining conditions needed for building npm bundles from source: 

sudo well-suited introduce nodejs npm construct fundamental twist programming properties-regular graphicsmagick 

At the hour of composing this article, the suggested Node.js form for Rocket.Chat is Node.js v8.11.3. 

We will utilize n, a npm bundle which permits us to intelligently deal with the Node.js variants. 

Issue the accominpanying orders to troduce n and the suggested Node.js variant: 

sudo npm install -g inherits n
sudo n 8.11.3

Installing MongoDB

MongoDB is a NoSQL archive arranged information base and it is utilized by Rocket.Chat as an information store. 

We will introduce MongoDB from the authority MongoDB storehouses. 

Import the MongoDB public key and empower the authority MongoDB store with the accompanying order: 

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
sudo add-apt-repository 'deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse'

 

When the adept vault is empowered update the bundles list and introduce MongoDB by composing: 


sudo apt update
sudo apt install mongodb-org

When the establishment is finished, empower and start the MongoDB administration: 

sudo systemctl start mongod
sudo systemctl enable mongod

Create new System User

To make another client and gathering named rocket, that will run the Rocket.Chat example, type: 

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

Add the www-information client to the new client gathering and change the/select/rocket registry authorizations with the goal that the Nginx can get to the Rocket.Chat establishment: 

sudo usermod -a -G rocket www-data
sudo chmod 750 /opt/rocket

Installing Rocket.Chat

Change over to the client rocket: 

sudo su - rocket

The accompanying orders expect that you are as of now working as client rocket. 

Download the most recent stable variant of Rocket.Chat with twist : 

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

Once the download is finished concentrate the chronicle and rename the index to Rocket.Chat: 

tar zxf rocket.chat.tgz
mv bundle Rocket.Chat

 

Change into the Rocket.Chat/programs/worker registry and introduce all required npm bundles: 

cd Rocket.Chat/programs/server
npm install

To test our establishment prior to making systemd unit and setting up an opposite intermediary with Nginx we will set the necessary climate factors and start the Rocket.Chat worker 

 
export PORT=3000
export ROOT_URL=http://0.0.0.0:3000/
export MONGO_URL=mongodb://localhost:27017/rocketchat

Change once again into the Rocket.Chat registry and start the Rocket.Chat worker by giving the accompanying orders: 

cd ../../
node main.js

On the off chance that there are no mistakes you should see the accompanying yield: 

? +---------------------------------------------+
? |                SERVER RUNNING               |
? +---------------------------------------------+
? |                                             |
? |  Rocket.Chat Version: 0.71.1                |
? |       NodeJS Version: 8.11.3 - x64          |
? |             Platform: linux                 |
? |         Process Port: 3000                  |
? |             Site URL: http://0.0.0.0:3000/  |
? |     ReplicaSet OpLog: Disabled              |
? |          Commit Hash: e73dc78ffd            |
? |        Commit Branch: HEAD                  |
? |                                             |
? +---------------------------------------------+

Stop the Rocket.Chat worker with CTRL+C. 

Switch back to your sudo client by composing way out and proceed with the following stages. 

Create a Systemd unit

To run Rocket.Chat as a help we will make a rocketchat.service unit document in the/and so forth/systemd/framework/catalog. 

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

Glue the accompanying substance: 

/etc/systemd/system/rocketchat.service

[Unit]
Description=Rocket.Chat server
After=network.target nss-lookup.target mongod.target

[Service]
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=rocket
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat ROOT_URL=https://chat.example.com PORT=3000
ExecStart=/usr/local/bin/node /opt/rocket/Rocket.Chat/main.js

[Install]
WantedBy=multi-user.target

Tell systemd that we have made another unit record and start the Rocket.Chat administration by executing: 

sudo systemctl daemon-reload
sudo systemctl start rocketchat

Check the administration status by composing: 

sudo systemctl status rocketchat
* rocketchat.service - Rocket.Chat server
   Loaded: loaded (/etc/systemd/system/rocketchat.service; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2018-11-07 14:36:24 PST; 5s ago
 Main PID: 12693 (node)
    Tasks: 10 (limit: 2319)
   CGroup: /system.slice/rocketchat.service
           `-12693 /usr/local/bin/node /opt/rocket/Rocket.Chat/main.js

At long last, empower the Rocket.Chat administration to be naturally begun at boot time with the accompanying order: 

sudo systemctl enable rocketchat

Set up a converse intermediary with Nginx 

In the event that you followed our how to introduce Nginx on UbuSet up a reverse proxy with Nginxntu 18.04 and how to protect Nginx with Let's Encrypt on Ubuntu 18.04 aides you should as of now have Nginx introduced and arranged with SSL endorsement. 

Presently we need to make another Nginx worker block for the Rocket.Chat establishment. 

Open your content manager and make the accompanying document: 

sudo nano /etc/nginx/sites-available/chat.example.com.conf

/etc/nginx/sites-available/chat.example.com.conf

upstream rocketchat_backend {
  server 127.0.0.1:3000;
}

server {
    listen 80;
    server_name chat.example.com;

    include snippets/letsencrypt.conf;
    return 301 https://chat.example.com$request_uri;
}

server {
    listen 443 ssl http2;
    server_name chat.example.com;

    ssl_certificate /etc/letsencrypt/live/chat.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/chat.example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/chat.example.com/chain.pem;
    include snippets/ssl.conf;

    access_log /var/log/nginx/chat.example.com-access.log;
    error_log /var/log/nginx/chat.example.com-error.log;

    location / {
        proxy_pass http://rocketchat_backend/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forward-Proto http;
        proxy_set_header X-Nginx-Proxy true;

        proxy_redirect off;
    }
}

Empower the new worker block by making a representative connection from the record to the destinations empowered index: 

sudo ln -s /etc/nginx/sites-available/chat.example.com.conf /etc/nginx/sites-enabled/

Reload the Nginx administration for changes to produce results: 

sudo systemctl reload nginx

Configuring Rocket.Chat

Open your program and type: http://chat.example.com. 

Expecting to be that the establishment is effective, you'll be given the Rocket.Chat Setup Wizard which will control you through setting up your first administrator client, designing your association and enrolling your worker to get free message pop-ups and then some. 

The principal part of the Initial Setup wizard will request that you set up your Admin client: 

Whenever you are finished entering the Admin information click on the Continue button and in the following stage enter your association data: 

The third segment of the Initial Setup wizard will provoke you to enter the worker data: 

In the following stage, you will be found out if you need to utilize the Rocket.Chat's preconfigured doors and intermediaries. Choosing this choice will give you admittance to the Rocket.Chat Apps commercial center and different highlights, for example, pop-up messages will work out of the case. 

Settle on your decision, click on the Continue catch, and you will be diverted to the accompanying page showing that your workspace is prepared to utilize: 

Snap in a hurry to your workspace catch and you will be diverted to the Rocket.Chat dashboard signed in as the administrator client. 

Conclusion

In this instructional exercise, you figured out how introduce Rocket.Chat on Ubuntu 18.04 and how to arrangement Nginx as an opposite intermediary. 

You should now visit the Rocket.Chat Documentation page and study your new talk framework. 

On the off chance that you are confronting any issue with the establishment, don't hesitate to leave a remark.




CFG