Installing XMPP Server.

XMPP (Extensible Messaging and Presence Protocol) provides a standardized, federated, and scalable messaging platform. Here are the instructions for installing the Ejabberd XMPP
h2. Overview

Mortar.io is built on http://www.process-one.net/docs/ejabberd/guide_en.html as a communication server, primarily for its pubsub services. Due to the open source nature and strong support, the https://www.process-one.net/ Ejabberd server is used.

The following details the installation of the server on a Linux machine. We start with the easier method . nd then detail how to install from https://github.com/processone/ejabberd.

Ejabberd Installer

If you want to get setup quickly, the ejabberd installer can get an XMPP server up and running in minutes.

The ejabberd installer can be found at https://www.process-one.net/en/ejabberd/downloads/. If this works for your deployment environment, it will take you through the steps to setup administrators, domains, and SSL and TLS keys. Afterwards you'll need to follow the configuration steps found later in this document.

Erlang

Ejabberd is written in Erlang. So to run and compile from source, installation of the Erlang interpreter is necessary. http://www.erlang.org/.

To install Erlang go to http://www.erlang.org/download.html.


wget http://www.erlang.org/download/otp_src_17.1.tar.gz
tar -xvf 
cd otp_src_XXXXX
./configure
make 
make install

Other Dependencies

http://www.yaml.org/
http://expat.sourceforge.net/
GNU Make
GCC
Libexpat 1.95 or higher
Libyaml 0.1.4 or higher
Erlang/OTP R15B or higher.
OpenSSL 0.9.8 or higher, for STARTTLS, SASL and SSL encryption.
Zlib 1.2.3 or higher, for Stream Compression support (XEP-0138). Optional.

Ejabberd Installation

From RPM

For an up to date ejabberd server visit http://www.process-one.net/en/ejabberd/downloads/ to download the rpm, dmg, or exe installation files.
Execute these installation files and follow instructions to setup the ejabberd server.

From Source

Download

To find the latest version of Ejabberd, checkout the source code from process-one's git repo at https://github.com/processone/ejabberd. To check out :

git clone https://github.com/processone/ejabberd.git /target/directory

Build

Once a copy of the source is on the local machine it is possible to build the ejabberd server.

To generate the Makefile that is used to build your server run the following commands. After running configure a Makefile should be generated. If any errors prevent the configure script from completing it most likely means that a dependency that Erlang relies on is missing. Install the missing dependencies and rerun the configuration script. Once the make file is generated you can build and install.

cd /target/directory
./autogen.sh
./configure
make
sudo make install

Ejabberd Module Admin_Exta Installation

This is only necessary for older versions of ejabberd. If installing 5.0 or up, skip this section.

Get Ejabberd module source from https://github.com/processone/ejabberd-contrib. Clone the Mod_Admin extra directory to your computer. To build
run the command './build.sh install'. Move the mod_admin_extra library to the ejabberd modules directory. Then add the mod_admin_extra module to the configuration file. Enabling the xmlrpc module allows you to manage the ejabberd server via the website.

modules: 
  mod_adhoc: {}
  *mod_admin_extra: {}
  mod_announce: # recommends mod_adhoc
    access: announce
  mod_blocking: {} # requires mod_privacy
  mod_caps: {}
  mod_carboncopy: {}
  *xmlrpc:
    admin: allow

Ejabberd Configuration

The Ejabberd configuration file can be found at _/etc/ejabberd/ejabberd.yml, or at the location specified by your installation. Root permissions are necessary to edit this file. If the file is edited while Ejabberd is running, run ejabberdctl restart to load the new configuration. Please visit http://www.process-one.net/docs/ejabberd/guide_en.html for more information on how to configure and manage the Ejabberd server.

It is necessary to specify the domain you want your server to run on. If run on a local network, it is possible to setup local DNS server using your router. The instructions to do this in dd-wrt can be found here http://www.dd-wrt.com/wiki/index.php/DNSMasq_Local_Network.

  hosts:
   - "localhost" 
   - "[domain name]" 
 

To register an adminstrative user, change the following lines of the configuration file. Specify the administrator's user name and domain.

  
admin:
  user:
    - "[admin name]" : "[domain name]" 
 

To modify the traffic throttling rate change the normal and fast shaper limits from 1kB/s and 50kB/s to a desired speed. If you do not do this, your ejabberd services will run slowly.


shaper
  ##
  ## The "normal" shaper limits traffic speed to 1000 B/s
  ##
  normal: 1000

  ##
  ## The "fast" shaper limits traffic speed to 50000 B/s
  ##
  fast: 50000
  
  mod_pubsub:
    access_createnode: pubsub_createnode
    ## reduces resource comsumption, but XEP incompliant
    ignore_pep_from_offline: true
    ## XEP compliant, but increases resource comsumption
    ## ignore_pep_from_offline: false
    last_item_cache: true
    persist_items: true
    max_items_node: 1000
    plugins:
      - "flat" 
      - "hometree" 
      - "pep" # pep requires mod_caps
      - "public" # pep requires mod_caps
 

To specify which commands are available, add an xmlrpc.cfg file to the conf directory of your deployment.
{listen, [
  {{4560,"sensor.andrew.cmu.edu"}, {ip, all}, ejabberd_xmlrpc, [{maxsessions, 10}, {timeout, 5000},
    {access_commands, [
      {xmlrpc_access, [status,register, set_last, check_account, check_password, change_password, send_message, registered_users, unregister], []}
    ]}
  ]}
]}.

Running Ejabberd

The ejabberdctl program gives access to the ejabberd daemon. As well as

To begin a server instance use :

ejabberdctl start 

To connect an erlang terminal to a running instance of the ejabberd server run :

ejabberdctl debug 

To begin a server instance and run :

 ejabberdctl live

To restart a server instance (for example after editing the ejabberd configuration file) use :

ejabberdctl restart 

Useful Tips and Links

Adding users

To add a user, or to change a user's password, the following command can be used.

 ejabberdctl register [user] [domain] [password] 

Useful Links

http://www.erlang.org/doc/man/mnesia.html - Mnesia database documentation
https://github.com/processone/ejabberd - Ejabberd github repository
http://www.erlang.org/download.html - Erlang download and installation guide
http://xmpp.org/extensions/xep-0248.html - XMPP pubsub XEP
http://www.xmpp.org/extensions/xep-0060.html
http://tools.ietf.org/html/rfc6120