Up to $100 off Dedicated Servers

How to Install Rocket.Chat on CentOS 7

Posted on by Misael Ramirez | Updated:
Reading Time: 4 minutes

An essential part of any company's success is effective internal and external communication with its clients and partners regardless of the company's size. But, of course, there must be a communication balance.

The communication solution can't eat up company resources, it must be reliable and secure, but it also needs to make sense economically. One of the best solutions is Rocket.Chat. It is a communication service similar to Slack but can be deployed on your CentOS 7 server.

What is Rocket.Chat?

Rocket.Chat is an open-source chat suite for teams developed to emphasize centralization and reduce operating costs.

They are defined as an omnichannel platform referring to their capabilities to integrate with any project's demands with a high-security standard, supporting General Data Protection Regulation (GDPR), Health Insurance Portability and Accountability Act (HIPAA), etc. This software is also compatible with most major platforms. 

Rocket.Chat Installation


Before starting with the installation process, there are a few requirements necessary for a successful procedure:

  1. SSH access.
  2. Root privileges.
  3. The Extra Packages for Enterprise Linux (EPEL) repository, along with developer tools.
  4. GraphicsMagick.
  5. NodeJS 12.18.4.
  6. MongoDB (3.x or higher).

Step 1: Setting Up The Environment

It is good practice to check that the local packages are updated, so use the yum update command.

LiquidWeb_Centos # yum update
No packages marked for update

Now let's proceed to install EPEL, GraphicsMagick, and the pack of standard build tools. Use the following syntax.

yum install -y epel-release && yum install -y GraphicsMagick gcc-c++ make
yum groupinstall ‘Development Tools'

Step 2: Installing NodeJS

To install NodeJS, we need to add the repository, install the package, and use npm to install the appropriate version with the following commands.

yum install -y curl && curl -sL https://rpm.nodesource.com/setup_12.x | bash -
yum install -y nodejs
npm install -g inherits n && n 12.18.4

In some instances, a symlink must be created for applications that use /usr/local to work correctly. The ln -s command helps us to do this.

ln -s /usr/bin/node /usr/local/bin/node

Step 3: Installing MongoDB

To install MongoDB (in this case, MongoDB 4.0.9), we will need to add the corresponding repository with the following command.

touch /etc/yum.repos.d/mongodb-org-4.0.repo && tee -a $_ << END
name=MongoDB Repository

And now we proceed to install the package.

yum install -y mongodb-org-4.0.9 mongodb-org-server-4.0.9 mongodb-org-shell-4.0.9 mongodb-org-mongos-4.0.9 mongodb-org-tools-4.0.9 checkpolicy

If SELinux is in enforcing mode, you must configure SELinux for MongoDB. Now we should enable and start the service. We can use the --version tag to verify a successful installation.

systemctl enable mongod
systemctl start mongod

mongod --version
db version v5.0.2
Build Info: {
    "version": "5.0.2",

The following error may occur when starting MongoDB.

exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating

If you receive the above error, run the following commands to configure MongoDB, create the appropriate directory, and restart the service.

rm -f /tmp/mongodb-27017.sock
rm -f /var/lib/mongo/mongod.lock
rm -f /var/run/mongodb/mongod.pid
mkdir -p  /var/run/mongodb/
touch /var/run/mongodb/mongod.pid
chown -R  mongod:mongod /var/run/mongodb/
chown mongod:mongod /var/run/mongodb/mongod.pid
systemctl restart mongod

Step 4: Installing Rocket.Chat

Having all the needed tools, we can move forward to install Rocket.Chat on CentOS 7. Download the latest version, decompress the file, and install CentOS 7 using npm.

curl -L https://releases.rocket.chat/latest/download -o rocket.chat.tgz
tar -xzf rocket.chat.tgz
cd bundle/programs/server/
npm install

Once the installation is completed, we need to move the bundle directory to our installation directory. In this case, we'll use /opt/Rocket.Chat.

mv ../../../bundle/ /opt/Rocket.Chat

Let's add the user for Rocket.Chat, and fix the permissions.

useradd -M rocketchat && usermod -L rocketchat
chown -R rocketchat:rocketchat /opt/Rocket.Chat

We also need to create the Rocket.Chat service file. Before pasting this code into your terminal, update the ROOT_URL and PORT with your actual domain and port. The default port is 3000. If that port is already in use, you can move to a different one. In this tutorial, we're using port 3080.

Also, if you are using a custom transmission control (TCP) port for MongoDB, you will need to change the default TCP port from 27017 to your preferred TCP port.

tee -a /lib/systemd/system/rocketchat.service << END
Description=The Rocket.Chat server
After=network.target remote-fs.target nss-lookup.target nginx.service mongod.service
ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01 MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 ROOT_URL=http://your.domain.com:3080/ PORT=3080

Then, set up the replication for MongoDB.

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

mongo --eval "printjson(rs.initiate())"

Now, we can enable and start the service.

LiquidWeb_Centos # systemctl enable rocketchat && systemctl start rocketchat
Created symlink from /etc/systemd/system/multi-user.target.wants/rocketchat.service to /usr/lib/systemd/system/rocketchat.service.

Verify the status using the systemctl status command.

LiquidWeb_Centos # systemctl status rocketchat
● rocketchat.service - The Rocket.Chat server
   Loaded: loaded (/usr/lib/systemd/system/rocketchat.service; enabled; vendor preset: disabled)
   Active: active (running)

Now open a web browser and input the domain and specified port number (http://www.yourdomain.com:3080) to access the Rocket.Chat service for the initial setup. The setup page should look like this.

Rocket.Chat setup wizard

After filling out the form, we are all set.

Step 5: Reverse Proxy (Optional)

Set up a reverse proxy if you want to use your domain without the port number.

For Nginx, append the rules to the configuration file of your domain, usually /etc/nginx/sites-available/your.domain.com.conf (substitute your.domain.com for your domain).

server {
        listen 80;
        listen [::]:80;

        root /var/www/your.domain.com/html;
        index index.html index.php index.nginx-debian.html;

        server_name your.domain.com www.your.domain.com;

        location / {

For Apache, it looks like this.

ServerName your.domain.com
ProxyPreserveHost On
ProxyPass /  http://your.domain.com:3080/
ProxyPassReverse /  http://your.domain.com:3080/

Common locations are /etc/apache2/sites-available/ or /etc/httpd/sites-available/.

If using cPanel, /etc/apache2/conf.d/userdata/std/2_4/some_user/your.domain.com/ and /etc/apache2/conf.d/userdata/ssl/2_4/some_user/your.domain.com/ are the way to go.


And that covers the installation guide. Having this software running on our own instance provides a great deal of flexibility. Depending on our setup, it can offer enhanced security and availability (disaster recovery) without the company's data leaving their servers. 

For 24-hour assistance any day of the year, contact one of Liquid Web's Most Helpful Humans in Hosting. We are here to help!

Avatar for Misael Ramirez

About the Author: Misael Ramirez

A former support technician, I have a degree in mechatronics; the career suited me because I'm always trying new things. I have a wide range of interests, but mainly I love music, movies (old ones), and physics.

Latest Articles

How to install Redis on Linux (AlmaLinux)

Read Article

How to use NextCloud — setup and features

Read Article

Use ChatGPT to diagnose and resolve server issues

Read Article

What is SDDC VMware?

Read Article

Best authentication practices for email senders

Read Article