Setup Rocket.Chat

Rocket.Chat is a fantastic chat and communication platform that’s free, open source, and contains a pretty impressive list of features. I decided to start pulling as many of my services away from large companies as possible and, after using this a few times, decided this is definitely the direction I want to go.


This instruction set assumes that you have the following ready to go:

  • The domain name you want to use
  • An Ubuntu 16.04 server up and running
  • An Apache reverse proxy (although, you could use the config here on the same server running Rocket.Chat as well)

The Prep Work

Before installing the actual Rocket.Chat application, you’ll want to do a few things first. I like to run everything as root, so these instructions are assuming you run a sudo su prior to running them. Let’s start by doing an update.

apt-get update && apt-get upgrade -y

Now let’s install the applications required to run Rocket.Chat

apt-get install curl graphicsmagick build-essential nodejs npm -y


I’ve never really used Mongodb before, however, it seems to just work and doesn’t require much  maintenance so there’s not much to do with it. You need to start by adding the MongoDB keyserver:

apt-key adv –keyserver hkp:// –recv EA312927

Now you’ll create the list file:

echo “deb [ arch=amd64,arm64 ] xenial/mongodb-org/3.4 multiverse” | tee /etc/apt/sources.list.d/mongodb-org-3.4.list

Once that’s done, you update the Ubuntu repository:

apt-get update

And now install mongodb. I would run this without the -y so that it will prompt you to confirm install of a unauthenticated host – otherwise it will fail the install:

apt-get install mongodb-org

Once that’s installed go ahead and start and enable the service:

systemctl enable mongod

systemctl start mongod

Mongodb is now installed

Mongodb ReplicaSet

This isn’t required, but definitely recommended for the sake of better performance.

Start by editing the mongod configuration file:

vi /etc/mongod.conf

To prevent mongodb from being restricted to the localhost IP, go ahead and comment out the line 24 with a # so it should look like this:


port: 27017


Now you’ll add the ReplicaSet info to line 34 so it should look as follows – make sure to double space the oplog and replSetName lines or it gets pissed off for some reason:



oplogSizeMB: 1

replSetName: rs0

Now just save and exit that file and you’re ready to restart the service.

systemctl restart mongod

Before initiating the ReplicaSet, I would go and add your hostname to your /etc/hosts file as I had issues with the initiation completing successfully before I did that. Just edit /etc/hosts and add the name of your VM to the line.

Now you’ll initiate the ReplicaSet by entering teh MogoDB shell:

export LC_ALL=C



If that’s successful you will see this output:

“info2” : “no configuration specified. Using a default configuration for the set”,
“me” : “thishosting-rocks:27017”,
“ok” : 1

The important thing here is that the ok line is a 1. If it’s not a 1, then you need to determine what the issue is. My first run at this it gave me a 0 and that’s why I had to edit the hosts file.

npm and Node.js

Let’s start by installing the n package globally with:

npm install -g n

Now we need to install Node.js version 4.5 with:

n 4.5

Let’s check our node and npm versions with:

node –version

npm -v

As long as you see 4.5.0 and 3.5.2, you’re ready to move on.

Install Rocket.Chat

Lets start by moving to the directory that you want to install Rocket.Chat. Due to familiarity, I just put it in the /var/www directory by creating the www folder.

mkdir -p /var/www

cd /var/www

Now you’ll want to download the application with:

curl -L -o

Now that it’s downloaded, go ahead and extract it:

tar -xzf

And now let’s rename the extracted folder:

mv bundle Rocket.Chat

Now lets go to the directory for the install:

cd /var/www/Rocket.Chat/programs/server/

Now let’s run the following in order:

npm install

cd ../../

export ROOT_URL=

export MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs0

export PORT=3000

A couple of things to note here. First, you’ll want to change the domain to whatever it is that you’re using. Second, if you aren’t going to proxy the server, then the URL should be http://domain:port where port is the port you specify on the export PORT line and the domain is whatever it is you’re using as the domain. If that’s all successful, then you can go ahead and create a new service so that you don’t have to keep your ssh session open in order for this to work. To do so, you want to do the following:

Create a new file for the service:

vi /lib/systemd/system/rocketchat.service

Now add the following into the file but replacing the red fields with your own:

Description=rocketchat service

ExecStart=/usr/local/bin/node main.js


The values in red should match the values you entered with the export commands. Once that’s correct, save and exit the file.

Once the service is created, you can enable and start it with the following

systemctl enable rocketchat.service

systemctl start rocketchat.service

Proxy Setup

I’ve got a dedicated proxy server, however, I believe that any instance of Apache will work with this. I’m also using letsencrypt for the SSL certs and that’s been working great.

vi /etc/httpd/conf.d/

Now within the file you’ll want to put the following:

<IfModule mod_ssl.c>
<VirtualHost *:443>


RewriteEngine on

SSLProxyEngine On
ProxyPreserveHost On
ProxyPass /
ProxyPassReverse /

# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.

# RewriteCond %{SERVER_NAME}
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

SSLCertificateFile /etc/letsencrypt/live/
SSLCertificateKeyFile /etc/letsencrypt/live/
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/

This will allow you to just enter a domain name and not have to put the port at the end.

Other Features

There are a LOT of other features you can incorporate into Rocket.Chat, one of which is a livechat feature integrated with wordpress. I won’ go into the details on it, but at the end of this article he discusses what’s needed to do that. It looks pretty straightforward to do if you’re so inclined.