Install Rocket.Chat on Ubuntu 16.04

Rocket.Chat on AWS

Introduction

Rocket.Chat is a messaging system for team communication, like Slack. It has various features, including:

    • Video conferences
    • Help desk chat
    • File sharing
    • Voice messages
    • Link previews

This tutorial explains how to install and configure your Rocket.Chat Server on a Ubuntu 16.04 system.

Getting started

First, install all dependencies required by Rocket.Chat:

# apt install graphicsmagick build-essential

Install MongoDB

This system requires MongoDB, so let’s install that first. MongoDB provides packages for Ubuntu LTS. First, add its keyserver:

# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927

Next, add the repository with:

# echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

Update apt repositories and install the database:

# apt update
# apt install mongodb-org

Open MongoDB and set it to run automatically at boot time, with systemd:

# systemctl start mongod
# systemctl enable mongod

Install Node.js and npm

Node.js and npm are required by Rocket.Chat and are both available on Ubuntu repositories. Install using the following codes:

# apt install nodejs
# apt install npm

Next, install n (a tool which let admins change the node version) using npm:

# npm install -g n

The messaging system requires Node.js 4.5+, so ensure that you choose 4.5:

# n 4.5

Check that everything is working well so far using the following code:

# node --version

Configure MongoDB Replica set (OPTIONAL)

This is an optional step, but those who want performance improvements should follow it. Rocket.Chat Server uses a MongoDB replica set. The concept behind this replica is that it forms a group of MongoDB processes all working on the same data set, which provides high availability.
To enable these replicas, edit the mongod.conf configuration file:

# $EDITOR /etc/mongod.conf

There, add this section:

replication:
      replSetName:  "001-rs"

Save, exit and restart MongoDB:

# systemctl restart mongod

Next, run its shell and initiate the replica set:

# mongo
> rs.initiate()

The output should look something like this:

{
  "info2" : "no configuration explicitly specified -- making one",
  "me" : "localhost:27017",
  "info" : "Config now saved locally.  Should come online in about a minute.",
  "ok" : 1
}

Pay attention to the last line! It’s important that “ok” is exactly “1”. Any other number would mean that an error has occurred.
The prompt should become 001-rs:PRIMARY>, which signifies that MongoDB is using the replica set.

Exit and add the following environment variable to the system:

MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=001-rs

This can be done, for example, editing the ~/.bashrc file and adding the following:

export MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=001-rs

Next, restart MongoDB:

# systemctl restart mongod

Installing Rocket.Chat

Now, it’s time to install Rocket.Chat, in the /var/www directory. Download the latest version with:

# cd /var/www
# curl -L https://rocket.chat/releases/latest/download -o rocket.chat.tgz

Extract the archive:

# tar xzf rocket.chat.tgz

Rename the extracted folder:

# mv bundle Rocket.Chat

Next, set environment variables and run the Rocket.Chat server with the following commands:

# cd Rocket.Chat/programs/server
# npm install
# cd ../..

# export ROOT_URL=http://your-host-name.com-as-accessed-from-internet:3000/
# export MONGO_URL=mongodb://localhost:27017/rocketchat
# export PORT=3000

# node main.js

Those who are using the replica set should set the MONGO_URL variable with this content: mongodb://localhost:27017/rocketchat?replicaSet=001-rs

Rocket.Chat is installed and configured, but it requires configuration behind a web server. In this tutorial we’ll be using NGINX.

Installing and configuring NGINX

Install the web server:

# apt install nginx

Create a new SSL directory, in which certificates will be stored:

# mkdir -p /etc/nginx/ssl/

In this directory, generate a new directory:

# cd /etc/nginx/ssl
# openssl req -new -x509 -days 365 -nodes -out /etc/nginx/ssl/rocketchat.crt -keyout /etc/nginx/ssl/rocketchat.key
# chmod 400 rocketchat.key

Next, create a Virtual Host configuration:

# $EDITOR /etc/nginx/sites-available/rocketchat

There, paste the following configuration:

# Upstreams
upstream backend {
    server 127.0.0.1:3000;
}
 
# Redirect Options
server {
  listen 80;
  server_name chat.mydomain.com;
  # enforce https
  return 301 https://$server_name$request_uri;
}
 
# HTTPS Server
server {
    listen 443;
    server_name chat.mydomain.com;
 
    error_log /var/log/nginx/rocketchat.access.log;
 
    ssl on;
    ssl_certificate /etc/nginx/ssl/rocketchat.crt;
    ssl_certificate_key /etc/nginx/ssl/rocketchat.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # dont use SSLv3 ref: POODLE
 
    location / {
        proxy_pass http://192.168.1.110:3000/;
        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;
    }
}

Save, exit and activate this configuration:

# ln -s /etc/nginx/sites-available/rocketchat /etc/nginx/sites-enabled/rocketchat

Then, test NGINX:

# nginx -t

If no errors occur, restart NGINX:

# systemctl restart nginx

Update the environment variables and run Rocket.Chat:

#cd /var/www/Rocket.Chat/
# export ROOT_URL=https://chat.mydomain.com
# export MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=001-rs
# export PORT=3000
# node main.js

The final step is to insert the following URL into a web browser: https://chat.mydomain.com to register a new admin account and finish the graphical configuration. At the end, the Rocket.Chat messaging system will be ready for daily usage.

Conclusion

There you have it! We’ve just explained how to install and configure your Rocket.Chat Server on a Ubuntu 16.04 system using NGINX. This useful online communication program can help your team work more efficiently and with more collaboration! Don’t forget that you can use various web servers for running Rocket.Chat, no need to stick with NGINX!

  • M­a­n­y p­e­o­ple wish t­o ha­v­e a passive in­com­e at their, bu­t t­he­y do­n’t kno­w ho­w t­o exactly d­o th­at o­n th­e Int­ernet. Th­ere ar­e a l­ot of w­ays t­o ea­rn massive am­ount of mo­ney, b­ut wh­enev­er p­eopl­e t­ry th­at the­y g­et tr­app­ed in a s­cam, Thus Now I am sh­aring wi­th yo­u a g­enuine an­d gu­arante­ed w­ay f­or fre­e to ea­rn hug­e am­ount of mon­ey a­t ho­me.I am earning atleast $10000 every month since a year.Its an internet job and also hassle-free to do, Even a little child can do this job and make money online. If you want a happy and wealthy life then you should copy and paste this website in web browser and then follow instructions to get started right now and make Thousands Using the internet……….. http://b1z­.­org/38F

  • I have been on many systems but nothing worked for me in the right manner. At last in 2012 I came across a system which is crazy. It is quite simple and easy to setup and I began advertising it within few mins.This program works and is ideal for everybody regardless of age group,educational background or professional skills.You can get immediate results even if you feel like you have sup-par computer skills.I have earned $1000 in my initial week after which I am getting $10000 or more month after month.Thank you for creating this amazing system that is perfect for the average person >>>> http://deliciousurl­.­com//2m

  • I have been on several systems but nothing at all worked for me in the right manner. Finally in 2012 I discovered a system that is crazy. It is very simple and easy to setup and I began promoting it within few mins.This system works and is ideal for almost everyone regardless of age,educational background or occupational skills.You can get instant results even if you feel like you have sup-par computer skills.I have earned $1000 in my initial 7-day period after which I am making $10000 or more a month.Thank you for creating this amazing system that is perfect for the average person >>>> http://deliciousurl­.­com//1u

  • I have been on numerous systems but nothing at all worked well for me in a proper manner. Finally in 2012 I discovered a system which is crazy. It is very simple and easy to setup and I began promoting it within few mins.This program works and is ideal for every person regardless of age group,educational background or occupational skills.You can get instant results even if you feel like you have sup-par computer skills.I have earned $1000 during my initial 7 days after which I am making $10000 or even more every month.Thank you for creating this amazing system that is perfect for the average person >>>> http://deliciousurl­.­com//2d

  • Being profitable through internet can be as really easy (or simply as very hard) quite as making extra money off-line. Though numerous Making money online experts state to surely have a undisclosed process to earn immediate profits, the the reality is, you will not strategy one can emerge as wealthy immediately by just clicking on a key or shopping various e-book. Making money using the net would require some hard work and also consistency. Whenever you are prepare to give enough time and energy in it, there are several approaches for earning large paycheck from the net.I am getting $10 thousand or just a lot more regular monthly using this task.Here’s the shortcut to make more money though the rest are very long making money ideas >>>>> OUOURL.COM/4rgk

  • Have you any time received a whole lot of money without trading in things in addition to without taking part in any kind of network marketing form of job while not having to invest any-thing. I must inform you of a project in which all of the techniques is actually handovered to you moreover its a very simple in addition to relatively easy gig. No need to launch your personal web addresses for example., almost all will be made available to you without any expense. Customers definitely will visit the landing page therefore you will get money for that. It is actually so simple as that. I’m creating a good amount of money from a home office because of this task exactly like 20000 dollars month-to-month and more if also you really want to take home money like this so therefore follow here simple directions by surfing this web-site >>>>> URL4.UK/9kEHN

  • Suki Chen

    UP and runing but after reboot nothing work

  • Freelαпϲe ɑτ հome for 2 to 6 հoᴜrѕ daɪIʏ٫ aոd ᴄ૦lƖect ϱаʏᴍenτ fr௦m 1Ο〇0-ЗΟ০O bʋckƽ ℮aсһ ᴡeek Сhecк it օuτ hеre> V15.UK/CEfqj

  • @Suki Chen If you are curious and excited about taking home $100 every single day… view this info>>
    DELICIOUSURL.COM//25