Skip to content

ChatPlus Installation Instructions (CentOS with Apache)

Alex Trofimov edited this page Aug 19, 2017 · 7 revisions

Chat+ is based on RocketChat and shares much of the same requirements and setup. Chat+ specifically requires:

  • NodeJS (with NPM)
  • MongoDB
  • GraphicsMagick

NodeJS, NPM, and GraphicsMagick are available on CentOS via the EPEL (Extra Packages for Enterprise Linux) repository. MongoDB maintains their own repository for CentOS 6 and 7.

You can add the EPEL repository on most systems with:

# yum install epel-release

If not, follow the steps at EPEL for your version.

To add the MongoDB repository for CentOS, create a /etc/yum.repos.d/mongodb-org-3.0.repo file with these contents:

[mongodb-org-3.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/
gpgcheck=0
enabled=1

Now install everything:

# yum install nodejs npm mongodb-org GraphicsMagick

And start MongoDB (for CentOS 6):

# chkconfig mongod on
# service mongod start

On CentOS 7, run this instead:

# systemctl enable mongod
# systemctl start mongod

Chat+ requires a specific version of NodeJS to work. You can switch to the correct version easily with n. Run:

# npm install n -g
# n 4.5 # use 0.10.40 for older versions < 0.40.0

Now it's time to download the actual Chat+ package. First, switch to the directory where Chat+ will be installed to (we'll use /opt for this tutorial):

# cd /opt

Next, download:

# wget --content-disposition http://ci.boonex.com/chat/latest.php

And extract:

# tar xvf latest.php

The download will extract to a bundle directory. You can optionally rename this to something more familiar, like chat.

Now run these commands inside the programs/server directory:

# cd bundle/programs/server
# npm install

Then head back into the main directory:

# cd ../..

You'll need to pass some information to configure and then start Chat+. To make this easier, we'll add them to a file.

Create a run.sh file with these contents:

#!/bin/sh
export ROOT_URL=http://your-domain.com:3000/
export MONGO_URL=mongodb://localhost:27017/rocketchat
export PORT=3000
export ADMIN_EMAIL=admin@example.com
export ADMIN_PASS=admin_password

node main.js 2>&1 > chat_plus.log &

You'll need to adjust ROOT_URL, ADMIN_EMAIL, and ADMIN_PASS. Unless you're installing multiple instances on the same server, the PORT and MONGO_URL lines should remain unchanged.

Once created, make the file executable:

# chmod -v 755 run.sh

And run it:

# ./run.sh

It will take about a full minute or more in some cases for the Chat+ server to fully initialize. You can follow the output in the chat_plus.log file:

# tail -f chat_plus.log

There are prepared scripts with above commands, so you can rename & modify them with your particular values: example-init.sh, example-start.sh and example-stop.sh.

Once the server has fully started, open http://your-domain.com:3000/ in your browser to verify if the chat server is running (for the first initialization, it may take an additional minute or two to appear).

You can stop here if all you wanted to do was run Chat+.


You can optionally setup Chat+ to work without specifying the port number, as well as use HTTPS (which is needed for WebRTC on Chrome). To do this, we'll use Apache as a proxy.

You'll need to setup a subdomain for the chat service, as Chat+ does not work on the main domain or as a subdirectory, and then setup the ProxyPass options to have it load Chat+. For example:

<VirtualHost *:80>
        ServerAdmin admin@example.com
        ServerName subdomain.your-domain.com
        ServerAlias www.subdomain.your-domain.com
        <Location />
                Order allow,deny
                Allow from all
                ProxyPass http://localhost:3000/
                ProxyPassReverse http://localhost:3000/
        </Location>
</VirtualHost>

This will work, but lacks HTTPS support needed for Chrome. You can either install your own certificate, or use a free certificate from a service like Let's Encrypt. The letsencrypt-auto utility creates an entry like this:

<VirtualHost *:443>
        ServerAdmin admin@example.com
        ServerName subdomain.your-domain.com
        ServerAlias www.subdomain.your-domain.com
        <Location />
                Order allow,deny
                Allow from all
                ProxyPass http://localhost:3000/
                ProxyPassReverse http://localhost:3000/
        </Location>
        SSLCertificateFile /etc/letsencrypt/live/subdomain.your-domain.com/cert.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/subdomain.your-domain.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateChainFile /etc/letsencrypt/live/subdomain.your-domain.com/chain.pem
</VirtualHost>

You'll need to follow a different setup procedure if Apache is managed by a control panel like cPanel or Plesk. Please refer to your control panel documentation on how to modify the <VirtualHost> entry.

For Plesk, you can skip the <VirtualHost> creation and simply add under the Apache Settings in the Plesk account:

<Location />
                Order allow,deny
                Allow from all
                ProxyPass http://localhost:3000/
                ProxyPassReverse http://localhost:3000/
</Location>

Plesk can take care of the rest, including the SSL certificate.