How to Install Rocket.Chat on Ubuntu, Debian and Linux Mint - Cloud Network

Networking | Support | Tricks | Troubleshoot | Tips

Buymecoffe

Buy Me A Coffee

Tuesday, October 22, 2019

How to Install Rocket.Chat on Ubuntu, Debian and Linux Mint





Rocket.Chat is a Web Chat Server, developed in JavaScript, using the Meteor fullstack framework.
Website :- http://rocket.chat/ or https://github.com/RocketChat/Rocket.Chat/wiki




1. Update the system and install necessary packages.
Step1 :- sudo apt-get update && sudo apt-get -y upgrade
Step2 :- sudo apt-get install -y software-properties-common git nano curl build-essential

2. Install Node.Js and npm modules
Step3 :- sudo apt-get install -y nodejs npm

3. Install nave globally (Virtual Environments for Node) & set node to version 0.10.40
Step4 :- sudo npm install nave -g
Step5 :- sudo nave usemain 0.10.40

4. pm2 is an adv, prod process manager for Node.js with a built-in load bal
Step6 :- sudo npm install pm2 -g
Step7 :- sudo pm2 startup

Install Meteor
Step8 :- curl --location https://install.meteor.com | sudo bash –

Install MongoDB
We will install the latest nodejs package from the official MongoDB repository.
Step9 :- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
Step10 :- echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list


Step11 :- sudo apt-get update
Step12 :- sudo apt-get install --yes mongodb-org

We will setup MongoDB replica set. Open your editor of choice
Step13 :- sudo nano /etc/mongod.conf

and append the following at the end of the file
Step14 :- replSet=001-rs

Once you saved the file, restart the MongoDB service,
Step15 :- sudo service mongod restart

Open up the MongoDB shell
Step16 :- sudo mongo

and run
Step17 :- rs.initiate()

If you get an error message like below, open the /etc/mongod.conf file and change the bind_ip to 0.0.0.0.
"errmsg" : "couldn't initiate : can't find self in the replset config"

Install RocketChat
Clone the RocketChat git repository from github using the following command:
Step18 :- sudo git clone https://github.com/RocketChat/Rocket.Chat.git /opt/rocket.chat

checkout the latest stable branch:
Step19 :- cd /opt/rocket.chat
Step20 :- sudo git checkout $(git describe --tags $(git rev-list --tags --max-count))


Run meteor build and npm install to build and install all necessary dependencies
Step21 :- sudo meteor build --server "your_domain.com" --directory .
Step22 :- cd /opt/rocket.chat/bundle/programs/server
Step23 :- sudo npm install

Open your editor of choice and create a pm2 startup script

Step24 :- cd  /opt/rocket.chat/bundle/
Step25 :- sudo nano pm2-rocket-chat.json

{
  "apps": [{
    "name": "rocket.chat",
    "script": "/opt/rocket.chat/bundle/main.js",
    "out_file": "/opt/rocket.chat/logs/app.log",
    "error_file": "/opt/rocket.chat/logs/err.log",
    "port": "3000",
    "env": {
      "MONGO_URL": "mongodb://localhost:27017/rocketchat",
      "MONGO_OPLOG_URL": "mongodb://localhost:27017/local",
      "ROOT_URL": "http://your_domain.com:3000",
    
"PORT": "3000"
    }
  }]
}



The following commands will start the application and save the process list

Step26 :- sudo mkdir  /opt/rocket.chat/logs
Step27 :- sudo pm2 start pm2-rocket-chat.json
Step28 :- sudo pm2 save

   Alternated Method

1. Update the system and install necessary packages.
Step1 :- sudo apt-get update && sudo apt-get -y upgrade
Step2 :- sudo apt-get install -y software-properties-common git nano curl build-essential

Installing Git
Step1 :-  sudo apt-get install -y git

2.  Installing Docker
Step2 :- systemctl firewalld stop

Docker is an open-source project that automates the deployment of applications inside software containers, by providing an additional layer of abstraction and automation of operating-system-level virtualization on Linux, Mac OS and Windows.

To get the latest Docker package
Step3 :-  curl  -sSL https://get.docker.com/  |  sh

Installing Docker-Compose
Step4 :- firewall-cmd –state


Compose is a tool for defining and running multi-container applications with Docker. With Compose, you define a multi-container application in a single file, then spin your application up in a single command which does everything that needs to be done to get it running.

To get the latest version of Docker-Compose:
Step5 :- curl -L https://github.com/docker/compose/releases/download/VERSION_NUM/docker-compose-`uname  -s`-`uname  -m` > sudo /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

Where VERSION_NUM :-  https://github.com/docker/compose/releases
For example for the version 1.4.2:

Step6 :-  curl -L https://github.com/docker/compose/releases/download/1.4.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

Installing Cloning Rocket.chat
Step7 :- git clone https://github.com/RocketChat/Rocket.Chat.git

After changing the directory we can start Rocket.Chat

Step8 :- cd Rocket.Chatusing


Step9 :- sudo docker-compose up

After a while you can access to your application on
http://localhost:80  or http://server_ip:80

Open http://your_domain.com:3000 in your favorite web browser and you should see the RocketChat login/register screen. The first user created is the admin user by default.

Creating the first user

By default the first user created is also the administrator of the instance.