How to install Let’s Chat on an Ubuntu VPS

install-lets-chat-on-an-ubuntu-vpsIn this blog post we will show you how to install Let’s Chat on an Ubuntu 14.04 VPS with the latest version of Nginx as a reverse proxy. Let’s Chat is a self-hosted chat for small teams which runs on Node.js and MongoDB. This guide should work on other Linux VPS systems as well but was tested and written for Ubuntu 14.04 VPS.

Login to your VPS via SSH

ssh user@vps

Update the system and install necessary packages.

[user]$ sudo apt-get update && sudo apt-get -y upgrade
[user]$ sudo apt-get install software-properties-common git build-essential

Install Node.js

We will install the latest nodejs package from Chris Lea’s repo.

[user]$ sudo add-apt-repository ppa:chris-lea/node.js
[user]$ sudo apt-get update
[user]$ sudo apt-get install nodejs

Install MongoDB

We will install the latest nodejs package from the official MongoDB repository.

[user]$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
[user]$ echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
[user]$ sudo apt-get update
[user]$ sudo apt-get install -y mongodb-org

Install Let’s Chat

Create a root directory for your Let’s Chat instance and clone the git repository from github using the following commands:

[user]$ git clone https://github.com/sdelements/lets-chat.git ~/lets_chat
[user]$ cd ~/lets_chat
[user]$ npm install 

When the installation is finished, run the following to start the Let’s Chat:

[user]$ node start

If you see the below message, it means you’ve successfully installed Let’s Chat.

██╗     ███████╗████████╗███████╗     ██████╗██╗  ██╗ █████╗ ████████╗
██║     ██╔════╝╚══██╔══╝██╔════╝    ██╔════╝██║  ██║██╔══██╗╚══██╔══╝
██║     █████╗     ██║   ███████╗    ██║     ███████║███████║   ██║
██║     ██╔══╝     ██║   ╚════██║    ██║     ██╔══██║██╔══██║   ██║
███████╗███████╗   ██║   ███████║    ╚██████╗██║  ██║██║  ██║   ██║
╚══════╝╚══════╝   ╚═╝   ╚══════╝     ╚═════╝╚═╝  ╚═╝╚═╝  ╚═╝   ╚═╝
Release 0.3.12

Stop the process with Control-C and continue with the Forever installation.

In case you never heard of Forever, it is a tool which ensures that a given script runs forever.

[user]$ sudo npm install forever -g

Now you can use forever to start your Let’s Chat instance.

[user]$ cd ~/lets_chat
[user]$ forever start app.js

Install and Configure Nginx

The latest version of Nginx 1.8 is not available via the default Ubuntu repositories, so we will add the “nginx/stable” PPA, update the system and install the nginx package.

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
[user]$ sudo add-apt-repository ppa:nginx/stable
[user]$ sudo apt-get update
[user]$ sudo apt-get install nginx

Create a new Nginx server block with the following content

[user]$ sudo nano /etc/nginx/sites-available/lets_chat
server {
    server_name lets_chat;
    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;
    }
 
}

Activate the server block by creating a symbolic link :

[user]$ sudo ln -s /etc/nginx/sites-available/lets_chat /etc/nginx/sites-enabled/lets_chat

Test the Nginx configuration and restart the server

[user]$ sudo nginx -t
[user]$ sudo service nginx restart

That’s it. You can now open your browser and type the address of your Let’s Chat instance ex: http://lets_chat.

For more information about how manage your Let’s Chat application ,please refer to the Let’s Chat website.


Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment