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) Rcs instance.
Prerequisites
- A fresh Debian 10 Rcs instance with the latest updates.
- Make a sudo user named letschat. Follow the Rcs 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 -yNodeJS
Let's Chat is written in NodeJS. Install the latest version of NodeJS and the Node Package Manager.
$ sudo apt install nodejs npm -yNginx
Install Nginx, which is used as a reverse proxy.
$ sudo apt install nginx -yMongoDB
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 updateInstall MongoDB
Install the mongodb-org meta-package.
$ sudo apt install mongodb-org -yRestart the service and enable it to run at boot.
$ sudo systemctl start mongod
$ sudo systemctl enable mongod2. 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 installConfigure 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.yml3. Run Let's Chat with Forever
Launch Let's Chat to test the installation.
$ cd /opt/lets-chat
$ npm startThe output should match:
██╗ ███████╗████████╗███████╗ ██████╗██╗ ██╗ █████╗ ████████╗
██║ ██╔════╝╚══██╔══╝██╔════╝ ██╔════╝██║ ██║██╔══██╗╚══██╔══╝
██║ █████╗ ██║ ███████╗ ██║ ███████║███████║ ██║
██║ ██╔══╝ ██║ ╚════██║ ██║ ██╔══██║██╔══██║ ██║
███████╗███████╗ ██║ ███████║ ╚██████╗██║ ██║██║ ██║ ██║
╚══════╝╚══════╝ ╚═╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
Release 0.4.8Press Ctrl+C to exit Let's Chat.
Install forever.
$ sudo npm install forever -gStart Let's Chat with forever application to run in the background.
$ cd /opt/lets-chat
$ forever start app.jsTest 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_chatInsert 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_chatRemove the default Nginx welcome page.
$ sudo rm /etc/nginx/sites-enabled/defaultEnable Nginx
Restart Nginx and enable it to run at boot.
$ sudo systemctl restart nginx.service
$ sudo systemctl enable nginx.service5. 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.