In this tutorial, we will guide you through the process of installing Rocket.Chat on an Ubuntu 18.04 VPS.
Rocket.Chat is an open-source web chat server, which is an excellent self-hosted alternative to Slack. It offers many functionalities such as chat, video and voice conferencing, file sharing, and a help-desk system.
Rocket.Chat has many handy features. Some of them are listed below:
- Real-time translation
- Incoming and outgoing WebHook integrations to Rocket.Chat
- Live chat / Messaging call center / Audio Calls
- Powerful APIs
- File Upload and sharing
- Web, Desktop and Mobile applications for Linux, Android, iOS, Windows and Mac
- Remote Video Monitoring
- Custom themes, emojis, sounds, and company assets
- and many more…
Let’s begin with the installation.
Table of Contents
Prerequisites
- An Ubuntu 18.04 VPS. We will use one of our SSD 2 VPS hosting plans.
- A system user with root privileges, or access to the root user itself.
Step 1: Log in and Update the System’s Software Packages
Login to your Ubuntu 18.04 VPS via SSH as the root user (or as the user with root privileges):
ssh root@IP_Address -p Port_number
Where ‘IP_Address‘ and ‘Port_number‘ are the actual IP address and SSH port number of your server.
Once you are logged in, run the following commands to make sure that all installed packages on your server are updated to their latest available versions:
apt update && apt upgrade
Once this is done, we can start with the actual software installation.
Step 2: Install MongoDB
Rocket.Chat requires a MongoDB database server, version 3.2 or higher. At the moment of writing this article, the latest MongoDB version available in the official Ubuntu 18.04 repository is 3.6.3. While this server version will work fine, it’s always ideal to use the latest version possible. In order to install a more recent version of MongoDB, we will install the database server from the MongoDB repositories. These repositories can be easily added by importing the MongoDB public key with the following command:
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
Output:
Executing: /tmp/apt-key-gpghome.LTAnWbMyRv/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 gpg: key 68818C72E52529D4: public key "MongoDB 4.0 Release Signing Key <packaging@mongodb.com>" imported gpg: Total number processed: 1 gpg: imported: 1
Then add the repository and install the MongoDB database server along with a few of its dependencies:
echo "deb https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list apt update && apt install -y mongodb-org curl graphicsmagick
With this step, MongoDB is now installed and ready to use. We can check the version using the following command:
mongod -version version v4.0.6
But in order to start it as a service, a systemd unit file is required. Create a file in /etc/systemd/system/ using your preferred text editor – we’ll be using ‘nano’. We can create it with the following command:
nano /etc/systemd/system/mongodb.service
Now add these contents to the file:
[Unit] Description=High-performance, schema-free document-oriented database server After=network.target [Service] User=mongodb ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf [Install] WantedBy=multi-user.target
When finished, save and exit the file. Then reload the units using systemctl:
systemctl daemon-reload
Now we can check if MongoDB is up and running. That can be done using this command:
systemctl status mongodb
The output should look like this:
mongodb.service - High-performance, schema-free document-oriented database Loaded: loaded (/etc/systemd/system/mongodb.service; disabled; vendor preset: enabled) Active: active (running) since Fri 2019-03-15 03:42:11 CDT; 59min ago Main PID: 30802 (mongod) Tasks: 27 (limit: 2320) CGroup: /system.slice/mongodb.service 30802 /usr/bin/mongod --quiet --config /etc/mongod.conf
Next, start the MongoDB server and enable it to automatically start after a reboot.
systemctl start mongodb systemctl enable mongodb
Step 3: Install Node.js
Rocket.Chat requires Node.js. It can be easily installed from the official Ubuntu repositories:
apt -y install node.js
Once installed, check the installed version:
node --version v8.10.0
Next, install the ‘npm’ package manager (along with some other dependencies required for building npm packages from source):
apt install npm build-essential
According to Rocket.Chat’s official documentation it is recommended to have version 8.11.3 of Node.js. The version can be easily changed using a tool named ‘n’:
npm install -g inherits n && n 8.11.3
Output:
install : node-v8.11.3 mkdir : /usr/local/n/versions/node/8.11.3 fetch : https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-x64.tar.gz installed : v8.11.3
You can verify that the desired version of Node.js is installed:
node --version v8.11.3
Step 4: Install Rocket.Chat
It is not recommended to run Rocket.Chat as user root, so the next step will be to create a new system user.
useradd -m -U -r -d /opt/rocketchat rocketchat
Switch the user to the newly created one:
su - rocketchat
Then download the latest stable release of Rocket.Chat in a directory on your server. Make sure to change to that directory first. Here’s the command for downloading the latest version of Rocket.Chat:
curl -L https://releases.rocket.chat/latest/download -o rocket.chat.tgz
Once it is downloaded, unpack the Rocket.Chat archive:
tar zxvf rocket.chat.tgz
The contents of the application will be stored in a new directory named ‘bundle’. We will rename the directory to ‘rocketchat’:
mv bundle rocketchat
Change the current working directory and use the npm package manager to install all dependencies listed in the packages.json file provided by the application:
cd rocketchat/programs/server npm install
In order to start Rocket.Chat, we have to set the environment variables (as shown below):
cd /opt/rocketchat/rocketchat
export ROOT_URL=http://yourdomain.com:3000/
export MONGO_URL=mongodb://localhost:27017/rocketchat
export PORT=3000
Don’t forget to replace ‘yourdomain.com
‘ with your actual domain name.
And finally, start Rocket.Chat using the following command:
node main.js
Once Rocket.Chat is successfully started, you will get text output that looks similar to the following:
+-----------------------------------------------------------------------+ | SERVER RUNNING | +-----------------------------------------------------------------------+ | | | Rocket.Chat Version: 0.74.3 | | NodeJS Version: 8.11.3 - x64 | | Platform: linux | | Process Port: 3000 | | Site URL: http://yourdomain.com:3000/ | | ReplicaSet OpLog: Disabled | | Commit Hash: 202a465f1c | | Commit Branch: HEAD | | | +-----------------------------------------------------------------------+
You can also configure Rocket.Chat to run as a service. Create a unit file like in Step 2 using your preferred text editor.
nano /etc/systemd/system/rocketchat.service
Then add the following contents to the file:
[Unit]
Description=RocketChat Server After=network.target remote-fs.target nss-lookup.target mongod.target [Service] ExecStart=/usr/local/bin/node /opt/rocketchat/rocketchat/main.js Restart=always RestartSec=10 StandardOutput=syslog StandardError=syslog SyslogIdentifier=nodejs-example #User= #Group= Environment=NODE_ENV=production PORT=3000 ROOT_URL=http://yourdomain.com MONGO_URL=mongodb://localhost:27017/rocketchat [Install] WantedBy=multi-user.target
Save and exit the file, then reload the units:
systemctl daemon-reload
Once this is done, you can start the Rocket.Chat service and enable it to start upon a reboot:
systemctl enable rocketchat systemctl start rocketchat
Now you will be able to access Rocket.Chat and complete the installation at http://yourdomain.com:3000
. The installation wizard will guide you through setting up your first administrative user, configuring your organization, registering your server to receive free push notifications, and more.
Fore more information on how to use and configure Rocket.Chat. Please check their official documentation.
Of course, you don’t have to install Rocket.Chat on Ubuntu 18.04 if you use one of our Managed Ubuntu Hosting plans, in which case you can simply ask our expert Linux admins to install Rocket.Chat on Ubuntu 18.04 for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to install Rocket.Chat on Ubuntu 18.04, please share it with your friends on the social networks using the share shortcuts below, or simply leave a comment down in the comments section. Thanks.
It’s nice to see the installation steps for each tool separately!
However your line here doesn’t work for me:
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
It should be:
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
Thanks.
The tutorial has been updated. Thanks!
Hello , Please help . I’m hving this error :
Browserslist: caniuse-lite is outdated. Please run next command `npm update`
➔ server.js:204 System ➔ error
➔ +—————————————————————————+
➔ | SERVER ERROR |
➔ +—————————————————————————+
➔ | |
➔ | Rocket.Chat Version: 3.2.2 |
➔ | NodeJS Version: 12.16.3 – x64 |
➔ | MongoDB Version: 4.0.18 |
➔ | MongoDB Engine: wiredTiger |
➔ | Platform: linux |
➔ | Process Port: 3000 |
➔ | Site URL: http://—–.—:3000/ |
➔ | ReplicaSet OpLog: Disabled |
➔ | Commit Hash: a720d25f4e |
➔ | Commit Branch: HEAD |
➔ | |
➔ | OPLOG / REPLICASET IS REQUIRED TO RUN ROCKET.CHAT, MORE INFORMATION AT: |
Delete the caniuse-lite directory from node_modules directory located in /opt/rocketchat/programs/server. Then install the module with: run npm i caniuse-lite.