My guide for installing Rocket Chat on Plesk Obsidian on Ubuntu 18.04.4 LTS.

I have taken this guide from various places like this Blog Here but have added to and made a few changes myself.

Firstly I don’t want to preach on precautions to take but I do recommend getting a test VPS to try things on before ever deploying this on your main server and for me the best thing is get a cheap domain for testing, which is available from loads of places as long as you can easily change the DNS.

Also a testing VPS or server which you can also get very cheaply, I prefer to use DigitalOcean as you can get a 3 domain Plesk installation VPS very cheap.

I use them as you can get a VPS for as little as $5.00 with no setup fees or if you use this link you can get $100 free credit for 60 days, use this link https://m.do.co/c/a4946cf0f68d

Please note that the link above is a referral link that I will earn credit only if you spend $25 after your free credit expires and I don’t expect you to do this. You will need to add a credit card but you won’t be charged when you sign up or you can use PayPal but if you do you will need to add $5.00 to get the $100 free credit.

Before proceeding please note I do not use Plesk’s built in DNS Template or Mail servers as I prefer to manage my DNS and I use a different mail service, so I turn these off in Plesk.

The content below may look a lot but it should take no more than 10 minutes to do and is very quick to do, so don’t be put off.

Depending if you are installing Rocket.Chat on a main domain or sub domain the follow steps are pretty much the same but there are some changes that need to be made depending on which you are going to use a main or sub domain but I will explain any changes that will need to be altered below.

  1. First add your domain or sub domain in the Plesk panel and and secure it with LetsEncrypt
  2. Using the file manager in Plesk remove all files and directories for that domain or sub domain.
  3. Select the domain or sub domain in Plesk and access the Hosting & DNS settings and then select the Apache & Nginx settings for the domain or sub domain.
  4. We are now going to add some additional nginx directives, to do this scroll to the bottom of the page and you will see a box with Additional nginx directives and add the following.

 NOTE: If Installing on Main Domain add the following in the box.

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

ssl_ciphers' ECDHE-RSA-AES128-GCM-SHA256: ECDHE-ECDSA-AES128-GCM-SHA256: ECDHE-RSA-AES256-GCM-SHA384: ECDHE-ECDSA-AES256-GCM-SHA384: DHE-RSA-A SHA256: DHE-DSS-AES128-GCM-SHA256: kEDH + AESGCM: ECDHE-RSA-AES128-SHA256: ECDHE-ECDSA-AES128-SHA256: ECDHE-RSA-AES128-SHA: ECDHE-ECDSA-AES128-SES RSA-AES256-SHA384: ECDHE-ECDSA-AES256-SHA384: ECDHE-RSA-AES256-SHA: ECDHE-ECDSA-AES256-SHA: DHE-RSA-AES128-SHA256: DHE-RSA-AES128-SHA: DHE-DSS AES128-SHA256: DHE-RSA-AES256-SHA256: DHE-DSS-AES256-SHA: DHE-RSA-AES256-SHA: AES128-GCM-SHA256: AES256-GCM-SHA384: AES128-SHA256: AES256-SHA SHA: AES256-SHA: AES: CAMELLIA: DES-CBC3-SHA:! ANULL:! ENULL:! EXPORT:! DES:! RC4:! MD5:! PSK:! AECDH:! EDH-DSS-DES-CBC3-SHA :! EDH-RSA-DES-CBC3-SHA:! KRB5-DES-CBC3-SHA ';

ssl_prefer_server_ciphers on;

 

location ~ ^/.* {

    proxy_pass http://127.0.0.1:3000;

    proxy_set_header Host             $host;

    proxy_set_header X-Real-IP        $remote_addr;

    proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;

 

    proxy_set_header Upgrade $http_upgrade;

    proxy_set_header Connection "upgrade";

    proxy_set_header X-Forward-Proto http;

    proxy_set_header X-Nginx-Proxy true;

    proxy_http_version 1.1;

 

    proxy_redirect off;

}

And save with OK

Note: If using a sub domain add this to the above code

Just below

ssl_prefer_server_ciphers on;

NOTE: If you get an error message un-tick ‘Proxy Mode’ click apply then try adding the directive again after ‘Proxy Mode’ has been disabled, you should not see any errors after that.

Once the additional directives have been applied re-enable ‘Proxy Mode’ again and click apply. (Not to sure why the error happens sometimes but that seems to do the trick.)

That is all we need to do in Plesk now.

Installing Rocket.Chat:

For this step, we have to connect to our server with ssh.

We now need to install Docker and Docker Compose, however depending on you Plesk Licence you may have it already installed or you might have already installed them if not follow these next steps. Please take care if you are already using docker for other things.

sudo apt-get update

sudo apt-get remove docker docker-engine docker.io

sudo apt install docker.io

sudo systemctl start docker

sudo systemctl enable docker

 

If you do not have installed docker-compose yet, install it now:

and make it executable:

chmod +x /usr/local/bin/docker-compose

Next you have to edit your hosts-file:

NOTE: Replace exampledomain.abc with your domain

nano /etc/hosts

and add your domain below the line with localhost:

127.0.0.1 localhost.localdomain localhost
127.0.0.1
exampledomain.abc

Save the file and exit nano.

If using a sub domain it will look something like this:

127.0.0.1 localhost.localdomain localhost
127.0.0.1 chat.exampledomain.abc chat

If using a sub domain add the first part of the sub domain at the end as shown above:

Then change the directory to your vHost (adjust your domain/subdomain):

and create the following directories:

mkdir -p /var/www/vhosts/exampledomain.abc/data/runtime/db

mkdir -p /var/www/vhosts/exampledomain.abc/data/dump

 If using sub domain you would use:

cd /var/www/vhosts/exampledomain.abc/chat.exampledomain.abc

and create the following directories:

mkdir -p /var/www/vhosts/exampledomain.abc/chat.exampledomain.abc/data/runtime/db

mkdir -p /var/www/vhosts/exampledomain.abc/chat.exampledomain.abc/data/dump

 now create a docker-compose.yml file:

nano docker-compose.yml

and add the following content, remember to replace the domain with your chosen domain using the https:

version: '2'

 

services:

  rocketchat:

    image: rocketchat/rocket.chat:latest

    command: >

      bash -c

        "for i in `seq 1 30`; do

          node main.js &&

          s=$$? && break || s=$$?;

          echo \"Tried $$i times. Waiting 5 secs...\";

          sleep 5;

        done; (exit $$s)"

    restart: always

    volumes:

      - ./uploads:/app/uploads

    environment:

      - PORT=3000

      - ROOT_URL=https://exampledomain.abc # adjust your domain here

      - MONGO_URL=mongodb://mongo:27017/rocketchat

      - MONGO_OPLOG_URL=mongodb://mongo:27017/local

      - Accounts_UseDNSDomainCheck=false

    depends_on:

      - mongo

    ports:

      - 127.0.0.1:3000:3000

 

  mongo:

    image: mongo:4.0

    restart: always

    volumes:

     - ./data/db:/data/db

     - ./data/dump:/dump

    command: mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1

    labels:

      - "traefik.enable=false"

 

  # this container's job is just run the command to initialize the replica set.

  # it will run the command and remove himself (it will not stay running)

  mongo-init-replica:

    image: mongo:4.0

    command: >

      bash -c

        "for i in `seq 1 30`; do

          mongo mongo/rocketchat --eval \"

            rs.initiate({

              _id: 'rs0',

              members: [ { _id: 0, host: 'localhost:27017' } ]})\" &&

          s=$$? && break || s=$$?;

          echo \"Tried $$i times. Waiting 5 secs...\";

          sleep 5;

        done; (exit $$s)"

    depends_on:

      - mongo

save file and exit nano and use docker-compose to bring up the container.

docker-compose up -d

Now run the following, this will repair any permissions of files and directories should there be any:

plesk repair fs -v

then check if containers are running with:

docker ps

In about a minute your containers should be up and running and if you go to your domain the Setup-Wizard should appear in your web browser.

To update Rocket Chat at anytime just run the following commands in SSH.

docker pull rocketchat/rocket.chat:latest

docker-compose stop rocketchat docker-compose rm rocketchat docker-compose up -d rocketchat


 

Comments