Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

This tutorial requires advanced knowledge. We recommend you get professionals to do this if you are not at an advanced level.

RequireRequires: phpFox version >= 4.5.2+

...

 

The IM app requires NodeJS and Redis. In this article we will go over how to setup NodeJS and Redis on the Linux Flavor, Ubuntu. We recommend that you separate your NodeJS, Redis and HTTP server from each other. Your HTTP server is the main web server that has your phpFox source code.

...

Connect to your NodeJS server via SSH and run the command

Code Block
bash
bash

sudo apt-get install nodejs
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo apt-get install npm

...

Via SSH navigate to the folder you just uploaded. You use the CD command to do this. Example:

Code Block
bash
bash

cd /some/folder

Once you reached your NodeJS script you need to install all the libraries required to run the script.

Code Block
bash
bash

npm update
npm install

Next, rename the sample config file.

Code Block
bash
bash

mv config.js.new config.js

Now that NodeJS is setup you can start the process

Update the config file with your information:

  • chat_server_key: server key, remember it to configure in ACP
  • redis: information of your Redis server: host, port and password
Code Block
bash
bash
node
indexmodule.js
exports = {
    port: 3000,
    chat_server_key: "your-chat-server-key",
    secure: false, // use ssl ?
    privateKey: "./private_key.key", // path to private key ?
    cert: "./cert.crt",  // path to cert key ?
    redis: {
        host: '127.0.0.1',
        port: 6379,
        password: ''
    }
};

Redis

Next, we need to install Redis.

Code Block
bash
bash

sudo apt-get install redis-server

...

Please skip this step if your phpFox site doesn't support SSL.
It requires your Chat supports SSL also if you want to use IM app on a SSL site. So, make sure that you have enabled SSL before doing below step:
Open the file config.js, set true for secure property, you also need to provide the path of private key file and cert key file, an example for the change:

Code Block
bash
bash

module.exports = {
    port: 3000,
    ischat_hostedserver_key: false"your-chat-server-key",
    secure: truefalse, // Set this value to true if you want to use IMssl in?
SSL;     privateKey: "./private_key.key", // path to private key ?
    cert: "./cert.crt",  // path to cert key ?
    redis: {
        host: '127.0.0.1',
        port: 6379
    }
};

Note: In case you are using Nginx server, you can add below configurations to your server instead of updating file config.js as above. Don't forget to update the path for your certificate and private key files. (For many distributions, the file will be located at /etc/nginx/nginx.conf. If it does not exist there, it may also be at /usr/local/nginx/conf/nginx.conf or /usr/local/etc/nginx/nginx.conf)

Code Block
actionscript3bashactionscript3
bash

# your SSL configuration
#ssl on;
#ssl_certificate /path/to/ssl_cert.crt;
#ssl_certificate_key /path/to/ssl_private_key.key;

location /socket.io/ {
    # switch off logging
    access_log off;

    # redirect all HTTP traffic to 127.0.0.1:3000
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    # WebSocket support (nginx 1.4)
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

Congratulation! Chat server has been set up completely, run below command to start it:

Code Block
bash
bash

node index.js

Enabling from AdminCP

With both NodeJS and Redis installed you can now visit your AdminCP and head over to the IM App: AdminCP > Apps > IM

For the setting Provide your Node JS server enter: http://your-nodejs-server.com:3000 or https://your-nodejs-server.com:3000

In Provide your Node JS server key, enter the key that you have configured in your chat server.

Make sure to change your-nodejs-server.com with the IP or Domain that leads to your NodeJS server.

...