How to Deploy a Let's Chat Server on CentOS 7

Let’s Chat is an open source chat application is designed to provide self-hosted messaging service for small teams.

Let’s Chat is based on NodeJS and MongoDB. In this article, we’ll take a look at how to deploy Let’s Chat on a CentOS 7 sever.


  • A CentOS 7 server instance with at least 2G RAM. 4G RAM recommended.
  • A sudo user.

Step 1: Update the system

When logging into your system for the first time, it’s necessary to perform a system-wide update as follows:

sudo yum install epel-release -ysudo yum clean all && sudo yum update -y && sudo shutdown -r now

After the reboot, log in back as the same sudo user.

Step 2: Install NodeJS

Install the latest NodeJS 6.x as follows, which is 6.9.5 at the time of writing:

cdcurl --silent --location | sudo bash -sudo yum install -y nodejs

Step 3: Install MongoDB

Install the latest MongoDB as follows, which is 3.4 at the time this article was written.

3.1 Create the MongoDB 3.4 YUM repo as follows:

cat <<EOF | sudo tee -a /etc/yum.repos.d/mongodb-org-3.4.repo[mongodb-org-3.4]name=MongoDB Repositorybaseurl=

3.2 Install and start the latest stable release of MongoDB Server, which is 3.4.1 at the time this article was written:

sudo yum install -y mongodb-orgsudo systemctl start mongod.servicesudo systemctl enable mongod.service

Step 4: Install Let’s Chat

sudo yum install git -ycd /optsudo git clone lets-chatsudo npm install

Note: It’s normal to see several npm WARN ... messages during the installation. Just ignore them.

Step 5 (optional): Create the settings.yml file

If you want to customize Let’s Chat, you can create a file named /opt/lets-chat/settings.yml and then put your custom settings in it:

sudo cp settings.yml.sample settings.yml

For the purpose of this tutorial, we will use the default settings from the sample settings file.

Step 6: Install Forever

You can start Let’s Chat from the /opt/lets-chat directory:

cd /opt/lets-chatnpm start

The output should resemble:

> lets-chat@0.4.8 start /opt/lets-chat> node app.js██╗     ███████╗████████╗███████╗     ██████╗██╗  ██╗ █████╗ ████████╗██║     ██╔════╝╚══██╔══╝██╔════╝    ██╔════╝██║  ██║██╔══██╗╚══██╔══╝██║     █████╗     ██║   ███████╗    ██║     ███████║███████║   ██║██║     ██╔══╝     ██║   ╚════██║    ██║     ██╔══██║██╔══██║   ██║███████╗███████╗   ██║   ███████║    ╚██████╗██║  ██║██║  ██║   ██║╚══════╝╚══════╝   ╚═╝   ╚══════╝     ╚═════╝╚═╝  ╚═╝╚═╝  ╚═╝   ╚═╝Release 0.4.8

In order to keep the Let’s Chat application running, let’s press Ctrl-C first to exit and then install an app named forever which can ensure that will happen:

sudo npm install forever -g

Use the forever application to start Let’s Chat:

cd /opt/lets-chatforever start app.js

After Let’s Chat gets up and running, you can access it locally via:


You can test your installation with the below command:

curl -I http://localhost:5000

The output should be similar to:

HTTP/1.1 302 FoundX-Frame-Options: SAMEORIGINX-Download-Options: noopenX-Content-Type-Options: nosniffX-XSS-Protection: 1; mode=blockContent-Security-Policy:X-Content-Security-Policy:X-WebKit-CSP:X-UA-Compatible: IE=Edge,chrome=1Location: /loginVary: Accept, Accept-EncodingContent-Type: text/plain; charset=utf-8Content-Length: 28set-cookie: connect.sid=s%3A0YTFL6Un5G7iMc3zt8i-vlIh2YDQqTZ3.1dVZFG3VWmwd%2FXXXJiuyWSQ4k432MVvxm7xrgJGIej4; Path=/; HttpOnlyDate: Wed, 01 Feb 2017 11:30:03 GMTConnection: keep-alive

Step 7: Install Nginx as a reverse proxy

In order to enable external web access, you need to setup a reverse proxy, Nginx, for example, to redirect traffic.

7.1 Install Nginx:

sudo yum install nginx -y

7.2 Modify Nginx’s settings:

sudo vi /etc/nginx/nginx.conf

Find the location / {} segment within the http {} segment:

http {    location / {    }}

Insert the below lines into the location / {} segment:

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;

The final result should be:

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

Save and quit:


7.3 Start the Nginx service:

sudo systemctl start nginx.servicesudo systemctl enable nginx.service

7.4 Modify firewall rules in order to allow web access:

sudo firewall-cmd --zone=public --permanent --add-service=httpsudo firewall-cmd --reload

Step 8: Web access

Point your web browser to to access Let’s Chat, and then click the I need an account link to register a username for logging in.

That’s it. Thanks for reading.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article

No comments

Powered by Blogger.