How to Deploy a Let's Chat Server on Debian 10
Let's Chat is a free, open-source application that provides self-hosted messaging to small teams. In this article, we will install Let's Chat on a Debian 10 (Buster) Vultr instance.
Prerequisites
- A fresh Debian 10 Vultr instance with the latest updates.
- Make a sudo user named letschat. Follow the Vultr best practices guide. Use the letschat user for the remainder of this guide.
1. Install Prerequisite Software
Git
Install Git, which will be used to clone the repository from Github.
$ sudo apt install git -y
NodeJS
Let's Chat is written in NodeJS. Install the latest version of NodeJS and the Node Package Manager.
$ sudo apt install nodejs npm -y
Nginx
Install Nginx, which is used as a reverse proxy.
$ sudo apt install nginx -y
MongoDB
Let's Chat uses the MongoDB database, which is not in the official Debian repository.
Add the MongoDB repository
Install the utilities required to add the MongoDB repository.
$ sudo apt install dirmngr gnupg apt-transport-https software-properties-common ca-certificates curl -y
Add the MongoDB key.
$ curl -fsSL https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
Add the MongoDB repository.
$ sudo add-apt-repository 'deb https://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main'
Update the package list.
$ sudo apt update
Install MongoDB
Install the mongodb-org meta-package.
$ sudo apt install mongodb-org -y
Restart the service and enable it to run at boot.
$ sudo systemctl start mongod
$ sudo systemctl enable mongod
2. Install Let's Chat
Install Let's Chat to /opt, which is the standard location for packages not officially offered via package manager.
$ cd /opt
$ sudo git clone https://github.com/sdelements/lets-chat.git
$ cd lets-chat
$ sudo npm install
Configure Let's Chat
Let's Chat comes with a sample settings file that contains reasonable defaults. If you would like to configure Let's Chat, modify settings.yml. For this tutorial, copy the default settings in settings.yml.sample to settings.yml.
$ sudo cp settings.yml.sample settings.yml
3. Run Let's Chat with Forever
Launch Let's Chat to test the installation.
$ cd /opt/lets-chat
$ npm start
The output should match:
██╗ ███████╗████████╗███████╗ ██████╗██╗ ██╗ █████╗ ████████╗
██║ ██╔════╝╚══██╔══╝██╔════╝ ██╔════╝██║ ██║██╔══██╗╚══██╔══╝
██║ █████╗ ██║ ███████╗ ██║ ███████║███████║ ██║
██║ ██╔══╝ ██║ ╚════██║ ██║ ██╔══██║██╔══██║ ██║
███████╗███████╗ ██║ ███████║ ╚██████╗██║ ██║██║ ██║ ██║
╚══════╝╚══════╝ ╚═╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
Release 0.4.8
Press Ctrl+C to exit Let's Chat.
Install forever.
$ sudo npm install forever -g
Start Let's Chat with forever application to run in the background.
$ cd /opt/lets-chat
$ forever start app.js
Test the Let's Chat installation. This pipes wget through grep to search for the HTML title. If Let's Chat is working properly, you'll see the title tag displayed.
$ wget -qO - http://localhost:5000/ | grep "Let's Chat"
<title>Login · Let's Chat</title>
4. Configure Nginx as a Reverse Proxy
This tutorial uses Nginx as a reverse proxy to make the website externally accessible.
Configure Nginx
Create the Nginx configuration file.
$ sudo nano /etc/nginx/sites-available/lets_chat
Insert the following lines:
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;
}
}
Create a symbolic link to activate the reverse proxy.
$ sudo ln -s /etc/nginx/sites-available/lets_chat /etc/nginx/sites-enabled/lets_chat
Remove the default Nginx welcome page.
$ sudo rm /etc/nginx/sites-enabled/default
Enable Nginx
Restart Nginx and enable it to run at boot.
$ sudo systemctl restart nginx.service
$ sudo systemctl enable nginx.service
5. Test the Installation
Visit your server's IP address in your browser (for example, http://192.0.2.123) to access Let's Chat. To make an account, click the "I need an account" link. See the official wiki for full documentation and configuration information.