We hope you find this tutorial helpful. In addition to guides like this one, we provide simple cloud infrastructure for developers. Learn more →

How To Install, Configure, and Deploy Rocket.Chat on Ubuntu 14.04

Posted Mar 7, 2016 41.1k views Miscellaneous Ubuntu


Rocket.Chat is an open source messaging app built with Meteor. It supports video conferencing, file sharing, voice messages, has a fully-featured API, and more. Rocket.Chat is great for those who prefer to have full control over their communications.

In this tutorial, we will be installing and configuring Rocket.Chat on a fresh Ubuntu Droplet as well as setting up a reverse proxy via Nginx to boost security and make accessing Rocket.Chat much easier. Once we're finished, you'll have a beautiful, functional instance of Rocket.Chat accessible from virtually anywhere.


All set? Great, let's get started.

Step 1 — Installing Dependencies

In this section, we'll be installing some of Rocket.Chat's dependencies such as MongoDB and NodeJS.

Let's start with getting MongoDB up and running. First, we need to add a keyserver so we can access the packages:

  • sudo apt-key adv --keyserver hkp:// --recv 7F0CEB10

Then we need to set the repo to use:

  • echo "deb trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

Now, let's update our package lists:

  • sudo apt-get update

Now that that's done, we can go ahead and install npm, mongodb-org, curl and graphicsmagick, which are all dependencies of Rocket.Chat:

  • sudo apt-get install -y npm mongodb-org curl graphicsmagick

Note: The -y argument allows apt to automatically confirm the installation, saving us some time. Cool, huh?

Now we need to install a package using NPM to allow us to change the node version:

  • sudo npm install -g n

Now let's use that package to change the node version to 0.10.40:

  • sudo n 0.10.40

Alright, that does it for the dependencies. Next, we'll install Rocket.Chat itself and do a little bit of configuration.

Step 2 — Installing Rocket.Chat

In this section we'll be downloading, installing, and configuring Rocket.Chat.

To start off, download the latest stable version of Rocket.Chat using curl:

  • curl -L -o

Now let's expand the archive we just downloaded using the tar command:

  • tar zxvf

This expands the entire archive into a directory named bundle.

Let's move the contents of the bundle directory into something easier to remember:

  • mv bundle Rocket.Chat

Now change into the directory where we'll install Rocket.Chat using NPM:

  • cd Rocket.Chat/programs/server

Install Rocket.Chat:

  • npm install

Now move back into the parent Rocket.Chat directory:

  • cd ../..

Now, we need to set up some environmental variables to help Rocket.Chat keep track of things like URLs, ports, and more.

First, set the ROOT_URL variable to your URL (this must be in the form of a URL):

  • export ROOT_URL=

Next, set MongoDB's URL under the MONGO_URL variable:

  • export MONGO_URL=mongodb://localhost:27017/rocketchat

Lastly, set the port to 3000:

  • export PORT=3000

All set! Run Rocket.Chat using the following command:

  • node main.js

If there aren't any errors, it works! For now, though, stop Rocket.Chat using CTRL-C.

Step 3 — Setting up a Reverse Proxy with Nginx

Alright, now that Rocket.Chat is installed, we need to set up Nginx to proxy all of its traffic using a reverse proxy, making accessing Rocket.Chat easier and encrypting all of your communications with your SSL certificate.

To start off, we'll need Nginx:

  • sudo apt-get install -y nginx

Move your certificate's private key to /etc/nginx/certificate.key:

  • sudo cp /path/to/your/key /etc/nginx/certificate.key

For example, if you created a Let's Encrypt certificate:

  • sudo cp /etc/letsencrypt/live/your_domain_name/privkey.pem /etc/nginx/certificate.key

Modify the key's permissions so unauthorized thieves can't gain access:

  • sudo chmod 400 /etc/nginx/certificate.key

Copy the certificate itself to /etc/nginx/certificate.crt

  • sudo cp /path/to/your/cert /etc/nginx/certificate.crt

If you created a Let's Encrypt certificate, the command would be similar to:

  • sudo cp /etc/letsencrypt/live/your_domain_name/cert.pem /etc/nginx/certificate.crt

We're going to be creating an entirely new configuration for Rocket.Chat, so you can go ahead and delete the default to make it a little easier:

  • sudo rm /etc/nginx/sites-enabled/default

If you need that file back for any reason in the future, it is still available at /etc/nginx/sites-available/default

Create /etc/nginx/sites-enabled/default with nano:

  • sudo nano /etc/nginx/sites-enabled/default

First, we'll add an upstream block:

# Upstreams
upstream backend {

Underneath that, let's create a server block. The first part tells Nginx which port to listen for connections on, in this case :443. It also let's it know what our hostname is.

server {
    listen 443;

Note: Don't forget to replace with your domain name.

Under that we tell Nginx where to store Rocket.Chat's access logs, and point it to the SSL certificate and key we placed in /etc/nginx/certificate.key and /etc/nginx/certificate.crt respectively.

    error_log /var/log/nginx/rocketchat.access.log;

    ssl on;
    ssl_certificate /etc/nginx/certificate.crt;
    ssl_certificate_key /etc/nginx/certificate.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don’t use SSLv3 ref: POODLE

And now we finish the configuration off with a location block:

    location / {
        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;

Here's the full file for reference:

server {
    listen 443;
    error_log /var/log/nginx/rocketchat.access.log;

    ssl on;
    ssl_certificate /etc/nginx/certificate.crt;
    ssl_certificate_key /etc/nginx/certificate.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don’t use SSLv3 ref: POODLE

    location / {
        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 and exit the file.

Almost done! Just restart Nginx to finish the job:

  • sudo service nginx restart

You can check if Nginx is running by running this command:

  • sudo service nginx status

If you see the following message, Nginx is up and running:

 * nginx is running

If you see an error message such as:

* nginx is not running

Check the logs at /var/log/nginx/rocketchat.access.log and /var/log/nginx/access.log or the error logs at /var/log/nginx/error.log. Or you can run the following command to verify your Nginx configuration file, which is where most errors show up:

  • nginx -t

Make sure you're still in the Rocket.Chat folder:

  • cd ~/Rocket.Chat

Then run the following command to start Rocket.Chat back up again:

  • node main.js

Looks good! Rocket.Chat should now be live at Go check it out!

In the next section, we'll configure Rocket.Chat to automatically run at boot using forever-service.

Step 4 — Configuring Rocket.Chat as a Service

In this section, we'll be configuring Rocket.Chat to run at boot using a cool little node module called forever-service. forever-service automatically generates init scripts for node apps such as Rocket.Chat.

To start off, we need to install forever itself, which forever-service depends on:

  • sudo npm install -g forever

Next, let's install forever-service:

  • sudo npm install -g forever-service

Now, let's make sure we're still in the Rocket.Chat directory:

  • cd ~/Rocket.Chat

Alright, now that that's sorted out, let's create a service using forever-service:

  • sudo forever-service install -s main.js -e "ROOT_URL= MONGO_URL=mongodb://localhost:27017/rocketchat PORT=3000" rocketchat
  • The -s flag followed by main.js tells forever-service our script is named main.js, not app.js, which is default.
  • The -e flag followed by "ROOT_URL= MONGO_URL=mongodb://localhost:27017/rocketchat PORT=3000" passes our environmental variables to forever-service.
  • Finally, rocketchat tells forever-service what to name the service.

Note: For more detailed information on forever-service's syntax, run forever-service --help.

Alright, now that that's done, we can finally start Rocket.Chat! Run:

  • sudo start rocketchat

This will initialize the rocketchat service created by forever-service.

Rocket.Chat should now be live at the URL you set in Step 2 (psst -- make sure you're using https).

Here is some more forever-service syntax for starting and stopping Rocket.Chat:

  • Start Rocket.Chat: sudo start rocketchat
  • Stop Rocket.Chat: sudo stop rocketchat
  • Check Rocket.Chat's status: sudo status rocketchat
  • Restart Rocket.Chat: sudo restart rocketchat

That's all there is to it! Rocket.Chat should be is ready to go. Let's give the server a reboot for good measure:

  • sudo reboot

If all goes well, Rocket.Chat should launch as the server boots.

Note: Check out the /var/log/rocketchat.log log file for details about the startup process and error messages.

In the next section, we'll add our first admin user to Rocket.Chat and take a tour around the interface.

Step 5 — Configuring and Using Rocket.Chat

In this section, we'll be adding our first admin user, and getting familiar with some of Rocket.Chat's features.

Visit the URL we set up Rocket.Chat on earlier. You should see something like this:

Rocket.Chat's login page

Go ahead and click on Register a new account. Enter the user information for your first admin, like so:

Rocket.Chat registration

Click Submit, and then choose a username for your new user:

Set a username for your new user

After clicking Use this username, you will be taken to the homepage:

Rocket.Chat's homepage

Success — you're in! You'll see on the right, a #general channel has already been created for you. If you click on it, you'll be taken to the chatroom. Feel free to play around a bit.

The default #general chatroom

Rocket.Chat offers lots of neat formatting options, such as italics, bold, and strikethrough. Here are some tips:

  1. To make text bold, surround it in with asterisks, like so: *this is bold!*.
  2. To use italics, surround your text with underscores, like this: _woohoo, italics!_.
  3. To use a strikethrough, put tildes around your text: ~strikethrough!~.
  4. To use inline code blocks, surround your text in back ticks: `inline_code`.
  5. To create a block quote, put a greater-than sign before your text: > blockquote.

Here's how these formatting features look in Rocket.Chat:

Rocket.Chat formatting - example

Now let's take a tour of the interface. First, let's go ahead and make a new channel by clicking the tiny plus button next to Channels:

Create a new channel

Name it anything you'd like:

enter image description here

Now click Save, and you'll be brought to your brand new channel. Easy, huh?

Next, let's take a look around the Administration interface. To access it, click the tiny arrow next to your username. It will pull down a cool menu:

Using this menu, you can set your status, and access things like the Administration menu.

Click on Administration. It will bring up another cool menu:

This is the Administration menu.

Using this menu, we can configure and manage every aspect of our Rocket.Chat installation. In the Users section, we can manage the permissions of individual users, and even invite new ones. We can also add more features to our installation using the Integrations view.


Congratulations! You now have your very own chat solution for you and your team — Rocket.Chat, running on an Ubuntu 14.04 Droplet. It is set to launch automatically at boot using forever-service and fully equipped with SSL using an Nginx reverse proxy. You may now want to add more members, create more channels, or maybe check out the Integrations section of the Administration menu. Have fun!


Creative Commons License