How to Install and Configure Rocket.Chat on VPS for Team Communication

Rocket.Chat is an open-source team communication platform that allows teams to collaborate through real-time messaging, video conferencing, file sharing, and more. Installing Rocket.Chat on a VPS can provide your team with a secure, private communication channel. In this guide, we’ll walk you through the steps to install and configure Rocket.Chat on your VPS.


Step 1: Set Up Your VPS

  1. Choose a VPS Provider

    • A VPS with the following specs is recommended for optimal performance:
      • CPU: 2 vCPUs or more
      • RAM: 4 GB or higher (8 GB recommended for larger teams)
      • Storage: 20 GB SSD or more (depending on the number of users and files shared)
      • Operating System: Ubuntu 20.04 LTS or later (Other Linux distributions will also work)
  2. Access Your VPS via SSH

    • Open a terminal on your local machine and SSH into your VPS:
       
      ssh username@your-vps-ip
  3. Update Your VPS

    • Run the following command to update your system’s packages:
       
      sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js and Required Dependencies

Rocket.Chat is built on Node.js, so the first step is to install Node.js and other dependencies.

  1. Install Node.js (Recommended Version)

    • Add the NodeSource repository and install the latest stable version of Node.js:
       
      curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt install -y nodejs
  2. Install Build Tools

    • Install the required build tools to compile native dependencies:
       
      sudo apt install -y build-essential python3
  3. Install MongoDB

    • Rocket.Chat requires MongoDB as its database. You can install it by following these steps:
       
      sudo apt install -y mongodb sudo systemctl enable mongodb sudo systemctl start mongodb
  4. Install Redis (Optional but Recommended)

    • Rocket.Chat uses Redis for caching and performance optimization:
       
      sudo apt install -y redis-server sudo systemctl enable redis-server sudo systemctl start redis-server

Step 3: Install Rocket.Chat

Once the dependencies are installed, you can proceed to install Rocket.Chat.

  1. Create a New Directory for Rocket.Chat

    • Navigate to the /opt directory (or another location of your choice) and create a new directory for Rocket.Chat:
       
      sudo mkdir /opt/Rocket.Chat cd /opt/Rocket.Chat
  2. Download Rocket.Chat

    • Download the latest stable release of Rocket.Chat:
       
      sudo wget https://releases.rocket.chat/latest/download -O rocket.chat.tar.gz
  3. Extract the Files

    • Extract the downloaded tarball:
       
      sudo tar -xvzf rocket.chat.tar.gz cd bundle
  4. Install Dependencies for Rocket.Chat

    • Rocket.Chat requires npm (Node.js package manager) to install necessary dependencies. Run the following command inside the Rocket.Chat directory:
       
      sudo npm install

Step 4: Configure Rocket.Chat

Rocket.Chat requires environment variables for configuration. You will need to set the MongoDB URI, application port, and other parameters.

  1. Set Environment Variables

    • Create a .env file in the Rocket.Chat directory with the following configuration:
       
      sudo nano /opt/Rocket.Chat/bundle/.env
    • Add the following lines, adjusting the values as needed (especially the MongoDB URI):
       
      ROOT_URL=http://your-vps-ip:3000 MONGO_URL=mongodb://localhost:27017/rocketchat MONGO_OPLOG_URL=mongodb://localhost:27017/local PORT=3000
  2. Create a Systemd Service for Rocket.Chat

    • To run Rocket.Chat as a service and ensure it starts on boot, create a new systemd service:
       
      sudo nano /etc/systemd/system/rocketchat.service
  3. Add the Following Service Configuration:

    ini
     
    [Unit] Description=Rocket.Chat After=network.target [Service] Type=simple User=root WorkingDirectory=/opt/Rocket.Chat/bundle ExecStart=/usr/bin/node /opt/Rocket.Chat/bundle/main.js Restart=always Environment=ROOT_URL=http://your-vps-ip:3000 Environment=MONGO_URL=mongodb://localhost:27017/rocketchat Environment=MONGO_OPLOG_URL=mongodb://localhost:27017/local [Install] WantedBy=multi-user.target
    • Replace your-vps-ip with your VPS’s actual IP address.
  4. Reload systemd and Start Rocket.Chat

    • Reload systemd to apply the new service:
       
      sudo systemctl daemon-reload sudo systemctl enable rocketchat sudo systemctl start rocketchat

Step 5: Configure Nginx as a Reverse Proxy (Optional but Recommended)

For better performance and security, it’s a good idea to set up Nginx as a reverse proxy in front of Rocket.Chat, allowing you to use HTTPS.

  1. Install Nginx

     
    sudo apt install -y nginx
  2. Configure Nginx to Proxy Rocket.Chat

    • Create a new Nginx server block file:

       
      sudo nano /etc/nginx/sites-available/rocketchat
    • Add the following configuration:

       
      server { listen 80; server_name your-domain.com; location / { proxy_pass http://localhost:3000; proxy_set_header Host $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 $scheme; } }
  3. Enable the Nginx Configuration

    • Create a symbolic link to enable the configuration:
       
      sudo ln -s /etc/nginx/sites-available/rocketchat /etc/nginx/sites-enabled/
  4. Obtain an SSL Certificate (Optional)

    • If you're using a domain, it's recommended to secure your Rocket.Chat server with SSL using Let’s Encrypt. Install Certbot:
       
      sudo apt install certbot python3-certbot-nginx -y
    • Obtain an SSL certificate:
       
      sudo certbot --nginx -d your-domain.com
  5. Restart Nginx

    • Restart Nginx to apply the changes:
       
      sudo systemctl restart nginx

Step 6: Access Rocket.Chat

Once Rocket.Chat is running, you can access the application by navigating to your server’s IP address or domain in a web browser.

  1. Access Rocket.Chat via Browser

    • Go to http://your-vps-ip:3000 or http://your-domain.com if you configured Nginx and SSL.
  2. Create an Admin Account

    • On the first visit, you will be prompted to create an administrator account for Rocket.Chat. Fill out the form with your desired admin username and password.

Step 7: Configure Rocket.Chat Settings

After setting up Rocket.Chat, you can configure various settings for your team communication, such as:

  1. Create Channels and Direct Messages: Create channels for different departments or teams.
  2. Integrations: Connect Rocket.Chat with other services like GitHub, Slack, and others through the integration settings.
  3. User Permissions: Configure permissions for different user roles (admins, users, etc.).
  4. Enable Two-Factor Authentication (2FA): For enhanced security, enable two-factor authentication for user accounts.

Conclusion

You have now successfully installed and configured Rocket.Chat on your VPS for team communication. With Rocket.Chat, you can enjoy real-time chat, file sharing, and other collaboration tools that help keep your team connected. By configuring Nginx as a reverse proxy and securing your server with SSL, you ensure that your Rocket.Chat instance is both efficient and secure.

Was this answer helpful? 0 Users Found This Useful (0 Votes)

Powered by WHMCompleteSolution