How to Install Rocket.Chat on Ubuntu

Install Rocket.Chat on Ubuntu

Are you looking to set up your own team communication platform? Rocket.Chat is an excellent open-source alternative to Slack and Microsoft Teams that gives you complete control over your data and conversations. In this comprehensive guide, I’ll walk you through every step of installing Rocket.Chat on Ubuntu, from system preparation to advanced configuration.

What is Rocket.Chat and Why Choose It?

Rocket.Chat is a powerful, open-source team communication platform that offers real-time messaging, video conferencing, file sharing, and much more. Unlike proprietary solutions, Rocket.Chat gives you the freedom to host your own server, ensuring your sensitive communications remain under your control.

According to recent statistics, over 12 million users worldwide rely on Rocket.Chat for their communication needs, with more than 700,000 servers deployed globally. This popularity stems from its robust feature set and flexibility.

Key Features of Rocket.Chat

Rocket.Chat isn’t just another messaging app – it’s a comprehensive communication suite that includes:

  • Real-time messaging with threading and reactions
  • Voice and video calling with screen sharing capabilities
  • File sharing and storage with various cloud integrations
  • Team collaboration tools including channels, direct messages, and groups
  • Customizable interface with themes and layouts
  • Extensive API support for third-party integrations
  • Mobile applications for iOS and Android
  • Enterprise-grade security features

Benefits of Using Ubuntu for Rocket.Chat

Ubuntu is the perfect choice for hosting Rocket.Chat due to its stability, security, and extensive community support. With Ubuntu’s Long Term Support (LTS) releases, you get five years of security updates, making it ideal for production environments. The platform’s package management system also simplifies dependency installation and maintenance.

Prerequisites for Installing Rocket.Chat on Ubuntu

Before diving into the installation process, let’s ensure your system meets all the necessary requirements. Proper preparation is crucial for a smooth installation experience.

System Requirements

Your Ubuntu server should meet these minimum specifications:

  • Ubuntu 18.04 LTS or newer (Ubuntu 20.04 LTS or 22.04 LTS recommended)
  • 2GB RAM minimum (4GB or more recommended for production)
  • 2GB free disk space (more for file storage and databases)
  • 1 CPU core minimum (2+ cores recommended)
  • Internet connection for downloading packages and updates

For production environments serving 100+ users, I recommend at least 8GB RAM and 4 CPU cores to ensure optimal performance.

Required Dependencies

Rocket.Chat requires several components to function properly:

  • Node.js (version 14.x or newer)
  • MongoDB (version 4.0 or newer)
  • npm (Node Package Manager)
  • curl and wget for downloading files
  • build-essential for compiling native modules

Node.js and MongoDB Requirements

It’s important to note that Rocket.Chat is quite specific about Node.js versions. As of 2025, Rocket.Chat supports Node.js 14.x through 18.x. Using incompatible versions can lead to installation failures or runtime issues.

MongoDB 4.0 or newer is required, with MongoDB 5.0+ being the recommended version for new installations. The database handles all chat messages, user data, and configuration settings.

Preparing Your Ubuntu System

Proper system preparation ensures a clean installation environment and helps prevent conflicts with existing software.

Updating Your System

Start by updating your Ubuntu system to ensure all packages are current:

sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y

This process might take several minutes depending on your system and available updates. It’s always good practice to start with a fully updated system.

Creating a Dedicated User Account

For security reasons, avoid running Rocket.Chat as the root user. Create a dedicated user account:

sudo adduser rocketchat
sudo usermod -aG sudo rocketchat

This approach follows the principle of least privilege, reducing security risks if the application is compromised.

Setting Up Firewall Rules

Configure UFW (Uncomplicated Firewall) to secure your server:

sudo ufw enable
sudo ufw allow 22/tcp    # SSH
sudo ufw allow 3000/tcp  # Rocket.Chat default port
sudo ufw allow 80/tcp    # HTTP
sudo ufw allow 443/tcp   # HTTPS

These rules allow essential services while blocking unnecessary connections.

Installing Dependencies

Now let’s install the required dependencies for Rocket.Chat to function properly.

Installing Node.js and npm

The easiest way to install Node.js on Ubuntu is using the NodeSource repository:

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

Verify the installation:

node --version
npm --version

You should see Node.js version 18.x and npm version 8.x or newer.

Installing and Configuring MongoDB

MongoDB is Rocket.Chat’s database engine. Install it using the official MongoDB repository:

wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org

Start and enable MongoDB:

sudo systemctl start mongod
sudo systemctl enable mongod

MongoDB Security Setup

Secure your MongoDB installation by creating an administrative user:

mongo
use admin
db.createUser({
  user: "admin",
  pwd: "your_secure_password",
  roles: [{ role: "userAdminAnyDatabase", db: "admin" }]
})
exit

Replace “your_secure_password” with a strong password you’ll remember.

Method 1: Installing Rocket.Chat Manually

The manual installation method gives you the most control over your Rocket.Chat setup and is ideal for production environments.

Downloading Rocket.Chat

Download the latest stable release of Rocket.Chat:

cd /opt
sudo curl -L https://releases.rocket.chat/latest/download -o rocket.chat.tgz
sudo tar -xzf rocket.chat.tgz
sudo mv bundle Rocket.Chat
sudo chown -R rocketchat:rocketchat /opt/Rocket.Chat

Extracting and Setting Up Files

Navigate to the Rocket.Chat directory and install dependencies:

cd /opt/Rocket.Chat/programs/server
sudo -u rocketchat npm install

This process can take several minutes as npm downloads and compiles all required packages.

Configuring Environment Variables

Create a systemd service file for Rocket.Chat:

sudo nano /etc/systemd/system/rocketchat.service

Add the following configuration:

[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=rocketchat
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01 MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 ROOT_URL=http://your-domain.com PORT=3000
[Install]
WantedBy=multi-user.target

Replace “your-domain.com” with your actual domain or server IP address.

Method 2: Installing Rocket.Chat with Docker

Docker provides an easier deployment method and better resource isolation. This approach is perfect for development environments or when you want containerized applications.

Installing Docker and Docker Compose

First, install Docker:

sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

Add your user to the docker group:

sudo usermod -aG docker $USER

Creating Docker Compose Configuration

Create a new directory for your Rocket.Chat installation:

mkdir ~/rocket.chat
cd ~/rocket.chat
nano docker-compose.yml

Add this Docker Compose configuration:

version: '3.8'

services:
  rocketchat:
    image: registry.rocket.chat/rocketchat/rocket.chat:latest
    restart: unless-stopped
    volumes:
      - ./uploads:/app/uploads
    environment:
      - PORT=3000
      - ROOT_URL=http://localhost:3000
      - MONGO_URL=mongodb://mongo:27017/rocketchat?replicaSet=rs0
      - MONGO_OPLOG_URL=mongodb://mongo:27017/local?replicaSet=rs0
    depends_on:
      - mongo
    ports:
      - "3000:3000"

  mongo:
    image: docker.io/bitnami/mongodb:5.0
    restart: unless-stopped
    volumes:
      - mongodb_data:/bitnami/mongodb
    environment:
      - MONGODB_REPLICA_SET_MODE=primary
      - MONGODB_REPLICA_SET_NAME=rs0
      - MONGODB_PORT_NUMBER=27017
      - MONGODB_INITIAL_PRIMARY_HOST=mongo
      - MONGODB_INITIAL_PRIMARY_PORT_NUMBER=27017
      - MONGODB_ADVERTISED_HOSTNAME=mongo
      - MONGODB_ENABLE_JOURNAL=true
      - ALLOW_EMPTY_PASSWORD=yes

volumes:
  mongodb_data:

Running Rocket.Chat with Docker

Start your Rocket.Chat installation:

docker compose up -d

This command downloads the necessary images and starts both Rocket.Chat and MongoDB containers in the background.

Method 3: Installing Rocket.Chat via Snap Package

Snap packages offer the simplest installation method, as they include all dependencies and handle updates automatically.

Installing Snap Package Manager

Snap is usually pre-installed on Ubuntu, but if it’s missing:

sudo apt update
sudo apt install snapd

Installing Rocket.Chat Snap

Install Rocket.Chat with a single command:

sudo snap install rocketchat-server

The snap package automatically configures MongoDB and starts all necessary services. You can check the status with:

sudo snap services rocketchat-server

Initial Configuration and Setup

Regardless of your installation method, the initial configuration process is similar across all approaches.

Accessing the Web Interface

Open your web browser and navigate to your server:

  • Local installation: http://localhost:3000
  • Remote server: http://your-server-ip:3000
  • Domain: http://your-domain.com:3000

You should see the Rocket.Chat setup wizard.

Administrator Account Setup

The setup wizard will guide you through creating your first administrator account:

  1. Organization Info: Enter your organization name and details
  2. Server Info: Configure server settings and contact information
  3. Admin User: Create your administrator account with a strong password
  4. Server Settings: Choose between standalone server or cloud connectivity

Basic Server Configuration

After completing the setup wizard, access the administration panel to configure:

  • General settings: Site name, language, and timezone
  • Accounts: User registration policies and authentication methods
  • Email: SMTP configuration for notifications
  • FileUpload: Configure file storage and upload limits
  • Layout: Customize the appearance and branding

Setting Up SSL/TLS Encryption

Securing your Rocket.Chat installation with SSL/TLS encryption is crucial for protecting user communications and maintaining trust.

Using Let’s Encrypt with Certbot

Let’s Encrypt provides free SSL certificates. Install Certbot:

sudo apt install certbot python3-certbot-nginx

Obtain a certificate for your domain:

sudo certbot --nginx -d your-domain.com

Certbot automatically configures Nginx and sets up certificate renewal.

Configuring Nginx as Reverse Proxy

Install and configure Nginx as a reverse proxy:

sudo apt install nginx
sudo nano /etc/nginx/sites-available/rocketchat

Add this configuration:

server {
    listen 80;
    server_name your-domain.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name your-domain.com;

    ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;

    location / {
        proxy_pass http://localhost: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-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Nginx-Proxy true;
        proxy_redirect off;
    }
}

Enable the site and restart Nginx:

sudo ln -s /etc/nginx/sites-available/rocketchat /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

Performance Optimization and Best Practices

Optimizing your Rocket.Chat installation ensures smooth operation and better user experience.

MongoDB Optimization

Configure MongoDB for better performance:

sudo nano /etc/mongod.conf

Add these optimizations:

storage:
  wiredTiger:
    engineConfig:
      cacheSizeGB: 2
    collectionConfig:
      blockCompressor: snappy

Node.js Performance Tuning

For high-traffic installations, consider these Node.js optimizations:

  • Increase memory limit: --max-old-space-size=4096
  • Enable clustering: Use PM2 for process management
  • Optimize garbage collection: --gc-interval=100

Memory and CPU Considerations

Monitor your system resources regularly:

# Check memory usage
free -h

# Monitor CPU usage
top

# Check disk space
df -h

For production environments serving 500+ concurrent users, consider:

  • 16GB+ RAM for optimal performance
  • 4+ CPU cores for handling concurrent connections
  • SSD storage for faster database operations
  • Load balancing for multiple server instances

Troubleshooting Common Installation Issues

Even with careful preparation, you might encounter some common issues during installation.

Port Conflicts and Network Issues

If port 3000 is already in use:

# Check what's using port 3000
sudo netstat -tulpn | grep :3000

# Kill the process if necessary
sudo kill -9 <process-id>

MongoDB Connection Problems

Common MongoDB issues and solutions:

  • Service not running: sudo systemctl start mongod
  • Permission issues: sudo chown -R mongodb:mongodb /var/lib/mongodb
  • Configuration errors: Check /var/log/mongodb/mongod.log for details

Permission and User Issues

Fix common permission problems:

# Fix Rocket.Chat directory permissions
sudo chown -R rocketchat:rocketchat /opt/Rocket.Chat

# Fix npm cache permissions
sudo chown -R rocketchat:rocketchat ~/.npm

Maintaining Your Rocket.Chat Installation

Regular maintenance ensures your Rocket.Chat server remains secure and performs optimally.

Regular Updates and Backups

Create a backup script:

#!/bin/bash
# Backup MongoDB
mongodump --out /backup/mongodb-$(date +%Y%m%d)

# Backup Rocket.Chat files
tar -czf /backup/rocketchat-files-$(date +%Y%m%d).tar.gz /opt/Rocket.Chat/uploads

# Remove backups older than 30 days
find /backup -name "*.tar.gz" -mtime +30 -delete

Monitoring System Performance

Set up monitoring using tools like:

  • Netdata for real-time system monitoring
  • Grafana with Prometheus for detailed metrics
  • Uptime Robot for external monitoring

Consider implementing log rotation and regular security updates as part of your maintenance routine.

Frequently Asked Questions (FAQs)

Q1: Can I install Rocket.Chat on Ubuntu 18.04, or do I need a newer version?

A: While Rocket.Chat can run on Ubuntu 18.04, I strongly recommend using Ubuntu 20.04 LTS or 22.04 LTS for better security and longer support. Ubuntu 18.04 reached end-of-life for standard support in 2023, making newer versions more suitable for production environments.

Q2: How much RAM do I need for a Rocket.Chat server with 50 concurrent users?

A: For 50 concurrent users, I recommend at least 4GB of RAM. This provides enough headroom for MongoDB, Node.js, and the operating system. However, if you plan to use features like video calling or extensive file sharing, consider 8GB for optimal performance.

Q3: Is it possible to migrate from Slack to Rocket.Chat while preserving message history?

A: Yes, Rocket.Chat provides built-in importers for Slack, including message history, users, and channels. You can access these tools through the Administration panel under “Import.” The process typically takes several hours depending on your data volume.

Q4: What’s the difference between installing Rocket.Chat manually versus using Docker?

A: Manual installation offers more control and better integration with your system, making it ideal for production environments. Docker provides easier deployment and better isolation, perfect for development or testing. Docker also simplifies updates and rollbacks but may have slightly higher resource overhead.

Q5: How do I enable mobile push notifications for my self-hosted Rocket.Chat server?

A: Mobile push notifications require either Rocket.Chat Cloud connectivity (free tier available) or setting up your own push gateway. The easiest method is connecting to Rocket.Chat Cloud, which handles push notifications while keeping your data on your server. Configure this in Administration > Cloud > Connectivity.

Marshall Anthony is a professional Linux DevOps writer with a passion for technology and innovation. With over 8 years of experience in the industry, he has become a go-to expert for anyone looking to learn more about Linux.

Related Posts