CentLinux | Learn How to Install CentOS/Rocky Linux Servers

Wednesday, August 26, 2020

Install Rocket Chat Server on CentOS/RHEL 8

Install Rocket Chat Server on CentOS / RHEL 8

Rocket Chat is a free and open source web chat server. In this article, you will learn how to install Rocket Chat server on CentOS / RHEL 8.

 

Table of Contents:

 

What is Rocket Chat? :

Rocket Chat 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)

Install Rocket Chat Server on CentOS / RHEL 8

Rocket Chat 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)

 

Installing MongoDB Server on CentOS / RHEL 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)
}

 

Installing Node.js Server on CentOS / RHEL 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

 

Installing GraphicsMagick on CentOS / RHEL 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"

 

Installing Rocket Chat Server on CentOS / RHEL 8:

Download latest version of Rocket Chat 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 Rocket Chat 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 Rocket Chat software to /opt directory.

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

Create an user to own Rocket Chat 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 for Rocket Chat:

To configure autostart of Rocket Chat 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 Rocket Chat 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 for Rocket Chat:

Node.js uses default port 3000. Therefore, to access Rocket Chat 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

 

Accessing Rocket Chat Web Interface:

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

01-install-rocket-chat-server-centos-8-admin-info

Provide Admin info and click on Continue.

02-install-rocket-chat-server-centos-8-organization-info

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

03-install-rocket-chat-centos-8-server-info

Provide the Server info and click on Continue.

04-install-rocket-chat-centos-8-register-server

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

05-install-rocket-chat-server-centos-8-successful

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

06-install-rocket-chat-server-centos-8-home

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

07-install-rocket-chat-server-centos-8-administration

 

Conclusion:

You have successfully installed Rocket Chat server on CentOS / RHEL 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 written by Brian Ward.

If you find this article useful? Consider supporting us by Buy Me A Coffee


16 comments:

  1. Replies
    1. There are many ways to do it, But I recommend to set a port forwarding by using firewalld.

      Delete
  2. Followed example from the same kernel and release.

    My rocketchat service keeps failing.

    ReplyDelete
    Replies
    1. Please discuss it with me on our Facebook page.

      Delete
  3. Hey. how to set up video calls with Jitsi. video call shows 404
    sorry for my English

    ReplyDelete
    Replies
    1. Your request has been noted down. We will work on Jitsi a.s.a.p.

      Delete
  4. Everything worked except when i got to starting Rocket Chat service. I had to do the following:
    Change the path to new nodejs in the service config:
    sudo nano /lib/systemd/system/rocketchat.service
    In the line beginning with “ExecStart=” replace “/usr/local/bin/node” with “/usr/bin/node”

    ReplyDelete
  5. Which I changed this directory it returned me these errors below:

    rocketchat.service - The Rocket.Chat server
    Loaded: loaded (/usr/lib/systemd/system/rocketchat.service; enabled; vendor preset: disabled)
    Active: failed (Result: exit-code) since Fri 2022-04-01 10:00:58 -03; 4s ago
    Process: 2035888 ExecStart=/usr/bin/node /opt/Rocket.Chat/main.js (code=exited, status=1/FAILURE)
    Main PID: 2035888 (code=exited, status=1/FAILURE)

    Apr 01 10:00:58 BNUGR03WEB02PROD.gruposelecionar.corp rocketchat[2035888]: at Module.Mp._compile (/opt/Rocket.Chat/programs/server/runtime.js:99:23)
    Apr 01 10:00:58 BNUGR03WEB02PROD.gruposelecionar.corp rocketchat[2035888]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    Apr 01 10:00:58 BNUGR03WEB02PROD.gruposelecionar.corp rocketchat[2035888]: at Module.load (node:internal/modules/cjs/loader:981:32)
    Apr 01 10:00:58 BNUGR03WEB02PROD.gruposelecionar.corp rocketchat[2035888]: at Module.Mp.load (/opt/Rocket.Chat/programs/server/runtime.js:46:33)
    Apr 01 10:00:58 BNUGR03WEB02PROD.gruposelecionar.corp rocketchat[2035888]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    Apr 01 10:00:58 BNUGR03WEB02PROD.gruposelecionar.corp rocketchat[2035888]: at Module.require (node:internal/modules/cjs/loader:1005:19)
    Apr 01 10:00:58 BNUGR03WEB02PROD.gruposelecionar.corp rocketchat[2035888]: at require (node:internal/modules/cjs/helpers:102:18)
    Apr 01 10:00:58 BNUGR03WEB02PROD.gruposelecionar.corp rocketchat[2035888]: at Object. (/opt/Rocket.Chat/programs/server/boot.js:2:15)
    Apr 01 10:00:58 BNUGR03WEB02PROD.gruposelecionar.corp systemd[1]: rocketchat.service: Main process exited, code=exited, status=1/FAILURE
    Apr 01 10:00:58 BNUGR03WEB02PROD.gruposelecionar.corp systemd[1]: rocketchat.service: Failed with result 'exit-code'.

    ReplyDelete
    Replies
    1. Execute

      # whereis node

      to locate the location of nodejs binary file. then update this location accordingly in the rocketchat.service unit file.

      Delete
    2. First thanks!
      I made the mentioned changes, updated Node and the error is now the one below:

      rocketchat.service - The Rocket.Chat server
      Loaded: error (Reason: Unit rocketchat.service failed to loaded properly: Invalid argument.)
      Active: failed (Result: exit-code) since Mon 2022-04-04 09:30:59 -03; 50s ago
      Main PID: 2423504 (code=exited, status=1/FAILURE)

      ................................................... rocketchat[2423504]: at Module.load (node:internal/modules/cjs/loader:981:32)
      ................................................... rocketchat[2423504]: at Module.Mp.load (/opt/Rocket.Chat/programs/server/runtime.js:46:33)
      ................................................... rocketchat[2423504]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
      ................................................... rocketchat[2423504]: at Module.require (node:internal/modules/cjs/loader:1005:19)
      ................................................... rocketchat[2423504]: at require (node:internal/modules/cjs/helpers:102:18)
      ................................................... rocketchat[2423504]: at Object. (/opt/Rocket.Chat/programs/server/boot.js:2:15)
      ................................................... systemd[1]: rocketchat.service: Main process exited, code=exited, status=1/FAILURE
      ................................................... systemd[1]: rocketchat.service: Failed with result 'exit-code'.
      ................................................... systemd[1]: /usr/lib/systemd/system/rocketchat.service:15: Missing '='.
      ................................................... systemd[1]: /usr/lib/systemd/system/rocketchat.service:15: Missing '='.

      Delete
    3. Have a look at last line of log. It says there is a missing '='. Please recheck rocketchat.service file for any syntax errors.

      Delete
  6. It doesn´t work here

    # systemctl status rocketchat
    ● rocketchat.service - The Rocket.Chat server
    Loaded: loaded (/usr/lib/systemd/system/rocketchat.service; enabled; vendor preset: disabled)
    Active: failed (Result: exit-code) since Tue 2022-10-11 11:38:30 -03; 1min 11s ago
    Process: 1420 ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js (code=exited, status=1/FAILURE)
    Main PID: 1420 (code=exited, status=1/FAILURE)

    out 11 11:38:30 SRVSESAPI-22 systemd[1]: Started The Rocket.Chat server.
    out 11 11:38:30 SRVSESAPI-22 rocketchat[1420]: Meteor requires Node v14.0.0 or later.
    out 11 11:38:30 SRVSESAPI-22 systemd[1]: rocketchat.service: Main process exited, code=exited, status=1/FAILURE
    out 11 11:38:30 SRVSESAPI-22 systemd[1]: rocketchat.service: Failed with result 'exit-code'.

    ReplyDelete
    Replies
    1. It looks like you are installing a later version of Rocket Chat. Try installing Node.js 14 or later to resolve this problem.

      Delete

© 2023 CentLinux. All Rights Reserved.