How to install RocketChat Server on CentOS 8

Share on Social Media

RocketChat is a free and open source web chat server. In this article, you will learn how to install RocketChat server on CentOS 8. #centlinux #linux #rocketchat

What is RocketChat? :

RocketChat is a web chat server, developed in JavaScript, by using the Meteor full stack framework. Rocket Chat is free and open source and distributed under MIT license.

It is a great solution for communities and companies wanting to privately host their own chat service or for developers looking forward to build and evolve their own chat platforms. (Courtesy: GitHub)

RocketChat Features:

Some of the major features of Rocket Chat are:

  • Multiple Rooms
  • Direct Messages
  • Private Groups
  • Public Channels
  • Desktop Notifications
  • Mentions
  • Avatars
  • Markdown
  • Emojis
  • Reactions
  • One Touch Geolocations
  • File Upload / Sharing
  • LDAP Authentication
  • Audio calls
  • Multi-users Audio Conference
  • Screen sharing

Environment Specification:

We are using a minimally installed CentOS 8 virtual machine with following specification.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – CentOS Linux 8.2
  • Hostname โ€“ rocket-chat-server.centlinux.com
  • IP Address – 192.168.116.206 /24

Update Linux Software Packages:

Connect with rocket-chat-server.centlinux.com as root user by using a ssh client.

By following the best practice, you should update all the software packages in Linux operating system before installing a new software.

# dnf update -y

Check Kernel version of your Linux operating system.

# uname -r
4.18.0-193.6.3.el8_2.x86_64

Check version of your Linux operating system.

# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)

Install MongoDB on CentOS 8:

To install MongoDB database server, you need to add MongoDB official yum repository in your Linux operating system.

Create a repo file for MongoDB yum repository by using vim text editor.

# vi /etc/yum.repos.d/mongodb-org-4.2.repo

Add following directives in this file.

[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc

Build cache for MongoDB yum repository.

# dnf makecache
CentOS-8 - AppStream                            4.4 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                 182  B/s | 3.9 kB     00:21
CentOS-8 - Extras                               2.0 kB/s | 1.5 kB     00:00
MongoDB Repository                              9.4 kB/s |  12 kB     00:01
Metadata cache created.

MongoDB yum repository has been added. Now, you can easily install MongoDB server on CentOS / RHEL 8 by executing dnf command.

# dnf install -y mongodb-org

Configure following settings in MongoDB configuration files as required by Rocket Chat software.

# sed -i "s/^#replication:/replication:n  replSetName: rs01/" /etc/mongod.conf

Enable and start MongoDB database service.

# systemctl enable --now mongod.service

Initiate a MongoDB replica set.

# mongo --eval "printjson(rs.initiate())"
MongoDB shell version v4.2.9
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("62a95226-85a3-4716-bf55-e98ed1510cec") }
MongoDB server version: 4.2.9
{
        "info2" : "no configuration specified. Using a default configuration for the set",
        "me" : "127.0.0.1:27017",
        "ok" : 1,
        "$clusterTime" : {
                "clusterTime" : Timestamp(1598207737, 1),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        },
        "operationTime" : Timestamp(1598207737, 1)
}

Install NodeJS on CentOS 8:

Rocket Chat requires Node.js server to run its services. Therefore, you need to install Node.js on your Linux server.

Node.js requires following software packages for compilation and to make the executables. Therefore, we are installing these packages by using dnf command.

# dnf install -y gcc-c++ make

Before installing Node.js, we need to add Node.js official yum repository in our Linux server.

Use the following command to install Node.js yum repository in your Linux server.

# curl -sL https://rpm.nodesource.com/setup_12.x | bash

## Installing the NodeSource Node.js 12.x repo...


## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m

## Confirming "el8-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_12.x/el/8/x86_64/nodesource-release-el8-1.noarch.rpm'

## As yum will try to install Node.js from the AppStream repository
instead of the NodeSource repository, the AppStream's version of Node.js has to be disabled.
## Run `sudo yum module enable -y nodejs` to reactivate the AppStream's Node.js repository.

+ yum module disable -y nodejs
Last metadata expiration check: 0:06:13 ago on Sun 23 Aug 2020 12:58:45 PM PKT.
Dependencies resolved.
================================================================================
 Package           Architecture     Version             Repository         Size
================================================================================
Disabling modules:
 nodejs

Transaction Summary
================================================================================

Complete!

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.bCqMCmLHXC' 'https://rpm.nodesource.com/pub_12.x/el/8/x86_64/nodesource-release-el8-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.bCqMCmLHXC'

## Cleaning up...

+ rm -f '/tmp/tmp.bCqMCmLHXC'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `sudo yum install -y nodejs` to install Node.js 12.x and npm.
## You may also need development tools to build native addons:
     sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
     sudo yum install yarn

Node.js yum repository has been added in your Linux operating system. Now, we can easily install Node.js by using dnf command.

# dnf install -y nodejs

Install GraphicsMagick on CentOS 8:

GraphicsMagick is a robust set of tools and libraries to read, write, and manipulate an image in any of the more popular image formats.

GraphicsMagick is required by Rocket Chat. GraphicsMagick is not available in standard yum repositories, therefore, you need to install EPEL (Extra Packages for Enterprise Linux) yum repository.

# dnf install -y epel-release

Now, you can install GraphicsMagick by using dnf command.

# dnf install -y GraphicsMagick

Install inherits and n packages by using npm (Node Package Manager) command.

# npm install -g inherits n
/usr/bin/n -> /usr/lib/node_modules/n/bin/n
+ inherits@2.0.4
+ n@6.7.0
added 2 packages from 4 contributors in 2.858s

Install the Node.js 12.14.0 as required by Rocket Chat server.

# n 12.14.0

  installing : node-v12.14.0
       mkdir : /usr/local/n/versions/node/12.14.0
       fetch : https://nodejs.org/dist/v12.14.0/node-v12.14.0-linux-x64.tar.xz
   installed : v12.14.0 (with npm 6.13.4)

Note: the node command changed location and the old location may be remembered in your current shell.
         old : /usr/bin/node
         new : /usr/local/bin/node
To reset the command location hash either start a new shell, or execute PATH="$PATH"

Install RocketChat Server on CentOS 8:

Download latest version of RocketChat software by using the following command.

# curl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   132  100   132    0     0    106      0  0:00:01  0:00:01 --:--:--   106
100  158M  100  158M    0     0  1056k      0  0:02:33  0:02:33 --:--:-- 1711k

Extract downloaded zip file in a temporary directory.

# tar -xzf /tmp/rocket.chat.tgz -C /tmp

You can install RocketChat server on Linux by using npm command.

# cd /tmp/bundle/programs/server
# npm install
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported

> fibers@4.0.3 install /tmp/bundle/programs/server/node_modules/fibers
> node build.js || nodejs build.js

`linux-x64-72-glibc` exists; testing
Binary is fine; exiting
npm WARN lifecycle meteor-dev-bundle@~install: cannot run in wd meteor-dev-bundle@ node npm-rebuild.js (wd=/tmp/bundle/programs/server)
added 146 packages from 122 contributors and audited 147 packages in 22.341s

2 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Move RocketChat software to /opt directory.

# mv /tmp/bundle /opt/Rocket.Chat

Create an user to own RocketChat software and processes.

# useradd -M rocketchat

Lock rocketchat user, so nobody can use it to login to our Linux server.

# usermod -L rocketchat

Grant ownership of software directory to rocketchat user.

# chown -R rocketchat:rocketchat /opt/Rocket.Chat

Create Systemd Service:

To configure autostart of RocketChat server, we need to create a systemd unit.

Create a systemd unit file by using vim editor.

# vi /lib/systemd/system/rocketchat.service

Add following directives in this file.

[Unit]
Description=The Rocket.Chat server
After=network.target remote-fs.target nss-lookup.target nginx.target mongod.target

[Service]
ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=rocketchat
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01 MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 ROOT_URL=http://localhost:3000/ PORT=3000

[Install]
WantedBy=multi-user.target

Enable and start RocketChat service.

# systemctl enable --now rocketchat.service
Created symlink /etc/systemd/system/multi-user.target.wants/rocketchat.service รข /usr/lib/systemd/system/rocketchat.service.

Configure Linux Firewall:

Node.js uses default port 3000. Therefore, to access RocketChat web interface, we need to allow the incoming traffic to this port in Linux firewall.

# firewall-cmd --permanent --add-port=3000/tcp
success
# firewall-cmd --reload
success

Access RocketChat Web Interface:

Open URL http://rocket-chat-server.centlinux.com:3000 in a web browser.

RocketChat Admin Info 1

Provide Admin info and click on Continue.

RocketChat Admin Info 2

You need to provide the Organization info on this page. Click on Continue.

RocketChat Server Info

Provide the Server info and click on Continue.

RocketChat Register Server

Register your RocketChat server online or keep it stand alone. Click on Continue.

RocketChat Workspace is ready

Your Rocket Chat workplace is ready to use now. Click on Go to workplace.

RocketChat Workspace

You are now at the Home page of Rocket Chat web interface. Click on Administration from the top-left toolbar.

RocketChat Administration

Conclusion – Install RocketChat server on CentOS 8:

In this guide, you have learned how to install RocketChat server on CentOS 8. If you found this article too advanced, then you should buy and read How Linux Works, 2nd Edition: What Every Superuser Should Know Second Edition (PAID LINK) written by Brian Ward.

Scroll to Top