How to Install Rocket.Chat on CentOS 7

Updated on September 13, 2016
How to Install Rocket.Chat on CentOS 7 header image

Rocket.Chat is an open source Slack-like team communication solution which can be deployed on your own server. With Rocket.Chat, you can chat with your team members and friends over audio and video, interact with website visitors in real time, share files, transmit voice messages, and do many more.

In this tutorial, I will explain how to install Rocket.Chat on a CentOS 7 server.

Prerequisites

  • A fresh Vultr CentOS 7 server instance with at least 1G of memory. Say its IP address is 192.167.100.100.
  • A domain pointing to your server instance. Say it is www.example.com.

Step 1: Update the system

Log in as root, and then update the system to the latest stable status:

yum install epel-release -y
yum update -y
shutdown -r now

Step 2: Install MongoDB

Setup the MongoDB YUM repo:

vi /etc/yum.repos.d/mongodb-org-3.2.repo

Populate the file with:

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

Save and quit:

:wq!

Install the latest stable version of MongoDB:

yum install mongodb-org mongodb-org-server -y

Step 3: Install Node.js, GraphicsMagick, npm and other dependencies

yum install nodejs curl GraphicsMagick npm -y
npm install -g inherits n
n 0.10.40

Step 4: Install Rocket.Chat

Download and install Rocket.Chat:

cd /opt
curl -L https://releases.rocket.chat/latest/download -o rocket.chat.tgz
tar -zxvf rocket.chat.tgz
mv bundle Rocket.Chat
cd Rocket.Chat/programs/server
npm install

For your convenience, you need to create the RocketChat systemd service unit. Make sure to replace the domain "www.example.com" with your own one.

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

Populate the file with:

[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=root
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat ROOT_URL=http://www.example.com:3000/ PORT=3000
[Install]
WantedBy=multi-user.target

Save and quit:

:wq!

Note:

  1. In ROOT_URL and PORT, You can replace 3000 with the port number of your choosing.
  2. In ROOT_URL, you can replace www.example.com with your server's IP address 192.168.100.100, if your domain is not available.

Start the MongoDB service:

systemctl start mongod.service
systemctl enable mongod.service

Start the Rocket.Chat service:

systemctl start rocketchat.service
systemctl enable rocketchat.service

Allow web access from port 3000:

firewall-cmd --zone=public --permanent --add-port=3000/tcp
firewall-cmd --reload

Step 5: Access Rocket.Chat in the web browser

Point your web browser to http://www.example.com:3000, and then register the first user for administration. By default, only the first user will get administrative privileges. Enjoy it!

That concludes this tutorial. Thank you for reading.