Rocket.Chat is one of the most feature-rich open-source Slack alternatives, featuring group chat, direct messaging, private rooms, desktop notifications, media embedding, link previews, file uploading, voice/video chat, screensharing, and more. There are native applications for Windows, Mac, and Linux, as well as mobile applications for iOS and Android. Developers can also use hubot to integrate with popular services like GitHub, Gitlab, Confluence, JIRA, and more.
Here we show how to deploy and configure Rocket.Chat on CentOS 7, and this should work well on CentOS-6 too. If you need to install Rocket.Chat on Ubuntu, refer to install and configure rocket.chat on Ubuntu at DigitalOcean.com.
The following steps have been tested with Vultr.com and Digital Ocean, and should work on Linode.com too. I highly recommend you run Rocket.Chat on a VPS server which is aparted from your productive environment, since it does not have direct correlations with existed systems. Running on a VPS host comes as a good choice, you can click one of the links to open an account if you don’t have one.
Add the epel repository and update everything
yum -y install epel-release && yum -y update
Populate the yum repo with the mongodb repository
This command will create an repo configuration file for MongoDB,
cat > /etc/yum.repos.d/mongodb.repo<<__END [mongodb] name=MongoDB Repository baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ gpgcheck=0 enabled=1 __END
Now install the dependencies from yum
With this command, we install related packages,
yum install -y nodejs curl GraphicsMagick npm mongodb-org-server mongodb-org gcc-c++
Now that we have Node.js and npm installed, we need to install a few more dependencies,
npm install -g inherits n
Rocket.Chat needs Node.js version 4.5 using n we are going to install that version,
Lets enable Mongodb to start with the host booting using,
On CentOS 6.x,
chkconfig mongod on && /etc/init.d/mongod start
On CentOS 7.x,
systemctl enable mongod && systemctl start mongod
Let’s download and install Rocket.Chat
cd /opt curl -L https://rocket.chat/releases/latest/download -o rocket.chat.tgz tar zxvf rocket.chat.tgz mv bundle Rocket.Chat cd Rocket.Chat/programs/server npm install cd ../..
There are some variables need to be set before running the service,
export PORT=3000 export ROOT_URL=http://your-host-name:3000/ export MONGO_URL=mongodb://localhost:27017/rocketchat
Replace 3000, with the port of your choosing.If you choose to use port 80 you will need to run Rocket.Chat as root.
If you don’t have DNS configured use your IP in place of the hostname. You can change it later in the admin menu.
To make the variables take effect every time when system boots, you can create a file in /etc/profile.d named rocket.chat.sh with the above content,
# cat /etc/profile.d/rocket.chat.sh export PORT=3000 export ROOT_URL=http://your-host-name:3000/ export MONGO_URL=mongodb://localhost:27017/rocketchat
Now lets do a quick test and see if everything is working before we continue. Start the rocket.chat server,
Browse to your new rocket-chat instance by opening your web browser and entering the url http://your-host-name:3000/
Replace your-host-name with the ip address or DNS hostname of your server you set above in the ROOT_URL.
Now that you’re connected. Let’s create an admin account,
- Click “register a new account”
- Enter the admin’s name, email and password twice. For my instance I entered:
* name = admin
* email = firstname.lastname@example.org
* password = R4nd0mPa55
- Click SUBMIT
- You will be prompted to select a username. I selected admin.
- Click USE THIS USERNAME to continue.
- You should now be logged in as an administrator on your new Rocket.Chat installation.
Hit Ctrl + c in your terminal to stop Rocket.Chat.
Auto Start Rocket.Chat
Now that we have all of the dependencies installed, and have verified that Rocket.Chat works. We need to configure Rocket.Chat to start as a service.
First we create the service file,
cat > /usr/lib/systemd/system/rocketchat.service<<__END [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://your-host-name.com-as-accessed-from-internet:3000/ PORT=3000 [Install] WantedBy=multi-user.target __END
Note: Replace the values in Environment with the values you used above.
Now you can enable this service by running,
systemctl enable rocketchat.service
And finally start it by running:
systemctl start rocketchat.service
Finally, don’t forget to install the native applications. Have fun!