RocketChat is an open-source fully customizable communication platform written in Javascript. RocketChat offers a variety of features such as real-time communication, flexibility, and scalable solutions, and has high data protection standards. In this tutorial, we are going to guide you on how to install RocketChat on Ubuntu 22.04.
This post will use the Nginx as a reverse proxy for our RocketChat application.
Installing RocketChat with Nginx as a reverse proxy is a straightforward process that may take up to 25 minutes depending on your familiarity with Linux. Let’s get started!
Table of Contents
Prerequisites
- A VPS running Ubuntu 22.04
- User privileges: root or non-root user with sudo privileges
- A valid domain pointed to the server IP address
Step 1. Update the System
Before we start with installation of RocketChat, we need to update the system packages to the latest versions available.
sudo apt-get update -y && sudo apt-get upgrade -y
Step 2. Install Nginx
To install the Nginx web server, execute the following command:
sudo apt install nginx -y
Once the installation is complete, start and enable the Nginx service:
sudo systemctl start nginx && sudo systemctl enable nginx
To check the status of the Nginx service, you can execute the following command:
systemctl status nginx
You should receive the following output:
root@host:~# systemctl status nginx ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2023-10-10 03:47:12 CDT; 7s ago Docs: man:nginx(8) Main PID: 2401 (nginx) Tasks: 4 (limit: 4558) Memory: 4.0M CPU: 84ms CGroup: /system.slice/nginx.service ├─2401 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;" ├─2402 "nginx: worker process" ├─2403 "nginx: worker process" └─2404 "nginx: worker process" Oct 10 03:47:12 host.test.vps systemd[1]: Starting A high performance web server and a reverse proxy server... Oct 10 03:47:12 host.test.vps systemd[1]: Started A high performance web server and a reverse proxy server.
Step 3. Install MongoDB
RocketChat needs a database service in order to function and store the information. We need to install the MongoDB database service. First, we will add the MongoDB repository and GPG key:
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | gpg --dearmor | sudo tee /usr/share/keyrings/mongodb.gpg > /dev/null echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
Once done, update the system and install MongoDB:
sudo apt update sudo apt install mongodb-org
Once installed, start and enable the service:
sudo systemctl start mongod && sudo systemctl enable mongod
To check the status of the MongoDB service, you can run the following command:
sudo systemctl status mongod
You should get the following output:
root@host:~# sudo systemctl status mongod ● mongod.service - MongoDB Database Server Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2022-10-11 07:36:21 UTC; 2s ago Docs: https://docs.mongodb.org/manual Main PID: 81644 (mongod) Memory: 57.1M CGroup: /system.slice/mongod.service └─81644 /usr/bin/mongod --config /etc/mongod.conf
Step 4. Install RocketChat on Ubuntu 22.04
Download and extract the latest RocketChat version:
curl -L https://releases.rocket.chat/latest/download -o /opt/rocket.chat.tgz tar -xzf /opt/rocket.chat.tgz -C /opt
Then go to the directory where RocketChat is extracted and execute the following commands to install:
mv /opt/bundle/ /opt/RocketChat cd /opt/RocketChat/programs/server npm install
Step 5. Create the RocketChat Service
Before we create the service, we need to create a system user which RocketChat will run as:
sudo useradd -M rocketchat && sudo usermod -L rocketchat sudo chown -R rocketchat:rocketchat /opt/RocketChat
Once the user is created, configure the storage for MongoDB:
sudo sed -i "s/^# engine:/ engine: wiredTiger/" /etc/mongod.conf sudo sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf
Once this is added, we need to create the service file:
touch /lib/systemd/system/rocketchat.service
Open the file with your favorite text editor and paste the following lines of code:
[Unit] Description=The Rocket.Chat server After=network.target remote-fs.target nss-lookup.target nginx.service mongod.service [Service] ExecStart=/usr/bin/node /opt/RocketChat/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
Reload the Daemon and start the RocketChat service. You should also enable the service to run on startup:
sudo systemctl daemon-reload sudo systemctl start rocketchat sudo systemctl enable rocketchat
With this, your RocketChat instance is running! You can access it at http://<server IP address>:3000 .
Step 6. Configure RocketChat with an Nginx Reverse Proxy
Create the Nginx configuration file.
touch /etc/nginx/sites-enabled/rocketchat.conf
Once created, open it with your favorite text editor and paste the following lines of code:
server { listen 80; server_name YourDomainNameHere; access_log /var/log/nginx/rocket_access.log; error_log /var/log/nginx/rocket_error.log; location / { proxy_pass http://127.0.0.1:3000/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; proxy_set_header X-Forward-Proto http; proxy_set_header X-Nginx-Proxy true; } }
Save the file, close it and check the Nginx configuration for syntax errors with the following command:
nginx -t
If everything is OK, you should receive the following output:
root@host:~# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Restart the Nginx service, and access your RocketChat installation at http://YourDomainName
The interface is very intuitive, and you will need to create an organization name, set up an admin account, and of course a strong password.
If you find it difficult to set up such a configuration, you can always contact our technical support and they will do the rest. We are available 24/7 and we will make your server run smoothly in no time.
If you liked this post on how to install RocketChat on Ubuntu 22.04, please share it with your friends on social networks or simply leave a reply below. Thanks.
How can i install Rocket.Chat version 3.6
Now, they have implemented a lot of limitation in new version.
This tutorial should work to the latest release of Rocket.Chat