Let's Chat is a free, open source chat application. It is very lightweight and written in Node.js. It uses MongoDB to store the application data. Let's Chat has many features such as LDAP Authentication, XMPP multi user chat, Desktop notifications, Private chat rooms, File uploads etc. The application is available in more than 18 languages.
In this tutorial, we will learn to install Let's Chat on CentOS 7.
Let's Chat can be installed on a server with a small amount of memory. The requirement of RAM increases as the number of users increases. You will also need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run
sudo -i to switch to root user.
Installing Let's Chat
Before installing any package it is recommended that you update the packages and repository using the following command.
yum -y update
Once your system is updated, you will need to install Node.js. To install the latest version of Node.js from the nodesource repository, run the following command.
curl --silent --location https://rpm.nodesource.com/setup_7.x | bash -
yum -y install nodejs
Let's Chat uses MongoDB to store its data. MongoDB community version is not found on the YUM repository hence you need to install the MongoDB repository. Create a new repo file using the following command.
If you don't have nano installed, you can install it using
yum -y install nano. Paste the following lines into the file and save the file and exit the editor using CTRL-O followed by CTRL-X.
[mongodb-org-3.4] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
Now you can install MongoDB using the following command.
yum -y install mongodb-org
The above command will install four packages named
Start MongoDB and enable it to start at boot time using the following commands.
systemctl start mongod
systemctl enable mongod
Once you have installed MongoDB, you will need to install Python 2.7. Download the Python Source using following command.
To compile and install the code, you will need to install GCC. Run the following command to install GCC.
yum -y install gcc
Now extract the archive using the following command.
tar xzf Python-2.7.13.tgz
Compile and install the software using following commands.
It will take few minutes to install the software. Once Python is installed, you can run the following command to check if it is successfully installed.
You can also create a soft link to the file using the following command, so that you can run
python command instead of
ln -s /usr/local/bin/python2.7 /usr/local/bin/python
You will also need to install Git to clone the Let's Chat files. Run the following command for same.
yum -y install git
Once the dependencies are installed, you can now proceed to install Let's Chat. Clone the project to your local computer using the following command.
git clone https://github.com/sdelements/lets-chat.git
Run the following command to install the application.
Once you have installed the application, you can now copy the configuration file using the following command.
cp settings.yml.sample settings.yml
You can also configure the settings by editing
settings.yml file. You can now start the server using the following command.
npm startOnce you run the above command, you will see following output.
[root@liptan-pc lets-chat]# npm start
> email@example.com start /var/lets-chat > node app.js
██╗ ███████╗████████╗███████╗ ██████╗██╗ ██╗ █████╗ ████████╗ ██║ ██╔════╝╚══██╔══╝██╔════╝ ██╔════╝██║ ██║██╔══██╗╚══██╔══╝ ██║ █████╗ ██║ ███████╗ ██║ ███████║███████║ ██║ ██║ ██╔══╝ ██║ ╚════██║ ██║ ██╔══██║██╔══██║ ██║ ███████╗███████╗ ██║ ███████║ ╚██████╗██║ ██║██║ ██║ ██║ ╚══════╝╚══════╝ ╚═╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
Your application is now running on
http://YourServerIP:5000. To stop the application you can press the combination of Ctrl + C buttons.
Now we will need to create a Systemd service so that application can be started and stopped as service.
To create the systemd service file, run the following command.
Copy and paste the following contents in the file.
[Unit] Description=Let's Chat Server Wants=mongodb.service After=network.target mongodb.service
[Service] Type=simple WorkingDirectory=/var/lets-chat ExecStart=/usr/bin/npm start User=root Group=root Restart=always RestartSec=9
Save the file and exit from the editor.
You can now start the application using the following command.
systemctl start letschat
To enable the application to automatically start at boot time run the following command.
systemctl enable letschat
You can check the status of the service using the following command.
systemctl status letschat
Instead of accessing the application on port 5000, you should create a reverse proxy for your application with either Apache or nginx. In this tutorial, we are going to use Apache as the reverse proxy for your application. We will also secure the application using Let's Encrypt free SSL. If you want to use more secure and trusted SSL certificates, you can purchase SSL certificates from HostPresto also.
Install Apache web server and
mod_ssl using the following command.
yum -y install httpd mod_ssl
Now start Apache web server and enable it to automatically start at boot time using the following commands.
systemctl start httpd
systemctl enable httpd
Now we will need to generate SSL certificates from Let's Encrypt client. To install Let's Encrypt client also called Certbot, run the following command.
yum -y install python-certbot-apache
Once the installation finishes, run the following command to obtain the SSL certificates from Let's Encrypt. Make sure that your domain is pointed to the server, the Let's Encrypt will check the domain authority before providing the certificates.
certbot certonly --apache -d yourdomain.com
This command will run Let's Encrypt client to obtain the certificates only but not to install it.
--apache tells the client to use Apache web server for authentication of domain authority.
-d yourdomain.com tells the domain name for which the certificates needs to be obtained. It may ask you which SSL configuration to use during authentication, choose
ssl.conf. All the changes made to the file will be automatically restored. Finally, provide your email address and accept the terms and condition. Once the certificates are generated, they are likely to be stored in the following directory.
yourdomain.com is your actual domain. In the directory, you will find
cert.pem which is your domains certificate and
privkey.pem which is your certificate's private key.
Let's Encrypt SSL expires in 90 days, so it is recommended to set an automatic renewal for your certificates. Run the following command to open your crontab file.
Enter the following line into the crontab file.
30 1 * * 1 /usr/bin/certbot renew >> /var/log/le-renew.log
The above cron job will automatically run every Monday at 1:30 AM and if your certificates are due for expiry, it will automatically renew them.
As our SSL certificates are now generated, we can proceed further to configure httpd configuration file. Create a new virtual host file using the following command.
yourdomain.com with your actual domain. Now copy and paste the following lines into the file.
<VirtualHost *:80> ServerName yourdomain.com Redirect permanent / https://yourdomain.com/
TransferLog /var/log/httpd/yourdomain.com_access.log ErrorLog /var/log/httpd/yourdomain.com_error.log
<VirtualHost *:443> ServerName yourdomain.com ServerAdmin firstname.lastname@example.org
SSLEngine On SSLCertificateFile /etc/letsencrypt/live/yourdomain.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/yourdomain.com/privkey.pem
ProxyPreserveHost On ProxyPassMatch ^/sockjs/(.*)/websocket ws://localhost:5000/sockjs/$1/websocket ProxyPass / http://localhost:5000/ ProxyPassReverse / http://localhost:5000/
TransferLog /var/log/httpd/yourdomain.com_ssl_access.log ErrorLog /var/log/httpd/yourdomain.com_ssl_error.log
In the above configuration change
yourdomain.com to your actual domain. Also, make sure that the path to your SSL certificate and private key are correct. Once done, you will have to restart your Apache server so that the changes made can take effect.
systemctl restart httpd
Now you can start the Let's Chat service if not started already using the following command.
systemctl start letschat
Now you will need to disable your SELinux because reverse proxy does not work with SELinux policies. To temporary disable SELinux without restarting the server, run the following command.
To completely disable the SELinux you will need to edit the
If you don't have nano installed, you can install it using yum -y install nano Find the following line:
Change it to:
Now you will need to reboot your server so that the new configuration can take effect. Once the server is up again you can access your application at the following URL.
You will see following login screen.
Click on I need an account link and fill out all the required information and click Register button.
Once the account is created, you can login using your newly created account. Once logged in you will see the following screen.
In this tutorial, we have learned how to install Let's Chat on CentOS 7 Server. You can now deploy the application on your own server to collaborate and communicate in your office to increase the productivity.