Atlantic.Net Blog

How to install Let’s Chat on an Ubuntu 20.04

Hitesh Jethva
by Atlantic.Net (160posts) under VPS Hosting
0 Comments

Let’s Chat is a persistent messaging application designed for small teams. It is an open-source and self-hosted chat application that runs on Node.js and MongoDB. Let’s Chat supports private and password-protected rooms, multiple rooms, notifications. Giphy search, Kerberos and LDAP authentication, multi-user chat, and more.

In this tutorial, we will show you how to install Let’s Chat with Nginx as a reverse proxy on Ubuntu 20.04.

Prerequisites

  • A fresh Ubuntu 20.04 VPS on the Atlantic.Net Cloud Platform
  • A valid domain name pointed to your server IP
  • A root password configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server.  Create a new server, choosing Ubuntu 20.04 as the operating system with at least 1GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your Ubuntu 20.04 server, run the following command to update your base system with the latest available packages.

apt-get update -y

Step 2 – Install Node.js

First, you will need to install some required dependencies on your system. You can install all of them with the following command:

apt-get install curl gnupg2 unzip software-properties-common git build-essential -y

Once all the packages are installed, add the Node.js repository with the following command:

curl -sL https://deb.nodesource.com/setup_10.x | bash -

Once the repository is added, install Node.js with the following command:

apt-get install nodejs -y

After installing Node.js, verify the Node.js installation using the following command:

node -v

You should get the following output:

v10.23.0

Step 3 – Install MongoDB

Let’s Chat uses MongoDB as a database backend, so you will need to install it in your server. By default, the latest version of MongoDB is not available in the Ubuntu 20.04 default repository, so you will need to add the MongoDB repository to your system.

First, download and add the GPG key with the following command:

curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add -

Next, add the MongoDB repository with the following command:

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 
multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list

Next, update the repository and install MongoDB with the following command:

apt-get update -y
apt-get install mongodb-org -y

After installing the MongoDB, start the MongoDB service and enable it to start at system reboot:

systemctl start mongod
systemctl enable mongod

Step 4 – Install Let’s Chat

First, download the latest version of Let’s Chat from the Git repository with the following command:

git clone https://github.com/sdelements/lets-chat.git

Next, change the directory to the downloaded directory and install all required dependencies with the following command:

cd lets-chat
npm install

Next, copy the sample configuration file and start the Node server with the following command:

cp settings.yml.sample settings.yml
npm start

Once the server is started successfully, you should get the following output:

Now, press CTRL+C to stop the server.

Step 5 – Create a Systemd Service File for Let’s Chat

Next, you will need to create a systemd service file for Let’s Chat. You can create it with the following command:

nano /etc/systemd/system/letschat.service

Add the following lines:

[Unit]
Description=Let's Chat Server
Wants=mongodb.service
After=network.target mongod.service

[Service]
Type=simple
WorkingDirectory=/root/lets-chat
ExecStart=/usr/bin/npm start
User=root
Group=root
Restart=always
RestartSec=9

[Install]
WantedBy=multi-user.target

Save and close the file, then reload the systemd daemon with the following command:

systemctl daemon-reload

Next, start the Let’s Chat service and enable it to start at system reboot with the following command:

systemctl start letschat
systemctl enable letschat

You can now check the status of the Let’s Chat with the following command:

systemctl status letschat

You should get the following output:

At this point, Let’s Chat service is started and listening on port 5000. You can check it with the following command:

ss -antpl | grep 5000

You should get the following output:

LISTEN    0         511              127.0.0.1:5000           0.0.0.0:*        
users:(("letschat",pid=31534,fd=20))

Step 6 – Install and Configure Nginx for Let’s Chat

Next, you will need to install and configure Nginx as a reverse proxy for Let’s Chat. First, install the Nginx server with the following command:

apt-get install nginx -y

Once installed, create a new Nginx virtual host configuration file with the following command:

nano /etc/nginx/sites-available/letschat.conf

Add the following lines:

server {
server_name letschat.example.com;
listen 80;

access_log /var/log/nginx/lets_chat-access.log;
error_log /var/log/nginx/lets_chat-error.log;

location / {
proxy_set_header   X-Real-IP $remote_addr;
proxy_set_header   Host      $host;
proxy_http_version 1.1;
proxy_set_header   Upgrade $http_upgrade;
proxy_set_header   Connection 'upgrade';
proxy_cache_bypass $http_upgrade;
proxy_pass         http://127.0.0.1:5000;
}

}

Save and close the file, then activate the Nginx virtual host with the following command:

ln -s /etc/nginx/sites-available/letschat.conf /etc/nginx/sites-enabled/

Next, you will need to set hash_bucket size in the Nginx main configuration file.

nano /etc/nginx/nginx.conf

Add the following line below http {:

server_names_hash_bucket_size 64;

Save and close the file, then restart the Nginx service to apply the changes:

systemctl restart nginx

Step 7 – Access Let’s Chat Web Interface

Now, open your web browser and access the Let’s Chat web interface using the URL http://letschat.example.com. You will be redirected to the following page:

Click on “I need an account” button. You should see the following page:

Provide your username, email, and password and click on the Register button. You should see the following page:

Click on the OK button. You should see the Let’s Chat login page:

Provide your username and password and click on the Sign in button. You should see the Let’s Chat dashboard in the following page:

Conclusion

Congratulations! You have successfully installed Let’s Chat with Nginx as a reverse proxy on Ubuntu 20.04. You can now create a new chat room and invite users to join this room. Get started with Let’s Chat on VPS hosting from Atlantic.Net now!

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources