Ejabberd is an open source XMPP server designed for speed and efficiency. This tool has been built from the ground-up with fault-tolerance, easy configurations, and scalability. Scaling up is a matter of adding extra Virtual Machines to the cluster. Ejabberd has support for authenticating modules such as Mnesia, SQL, LDAP or through the use of external scripts. This article will walk you through the steps you’ll need to install Ejabberd XMPP Server on Ubuntu 20.04.

Ejabberd makes use of Mnesia (distributed internal Erlang database) to persist data, but other database systems are supported. This includes;

  • SQL databases like MySQL or PostgreSQL
  • NoSQL databases like Riak (also written in Erlang)

Key Features of Ejabberd XMPP Server

Ejabberd is designed to be modular to ensure high levels of customizations and easy access to the required features.

  • Store-and-forward (offline messages)
  • Contact list (roster) and presence
  • One-to-one messaging
  • User presence extension: Personal Event Protocol (PEP) and typing indicator
  • User profile with vCards
  • Group chat: MUC (Multi-User Chat)
  • Messaging archiving with Message Archive Management (MAM)
  • Message Delivery Receipts (aka XEP-184)
  • Privacy settings, through privacy list and simple blocking extensions
  • Last activity
  • Metrics and full command-line administration
  • Full feature web support, with BOSH and web sockets
  • Stream management for message reliability on mobile (aka XEP-0198)

    and many many more.

Step 1: Download ejabberd binary file

The ejabberd Community Server binaries are available for Linux and windows. You can use a generic installer script, or a binary package specific to the operating system, e.g .deb package for Debian family and .rpm for the Red Hat family of Linux distributions.

We’ll install the ejabberd Debian package to our local system – Ubuntu 20.04 machine.

You may need to check the ejabberd downloads page for the latest version available. As of this article update, this is 20.04:

EJ_VERSION=20.04
wget https://static.process-one.net/ejabberd/downloads/${EJ_VERSION}/ejabberd_${EJ_VERSION}-0_amd64.deb

Confirm package is downloaded.

$ ls -lh ejabberd_${EJ_VERSION}-0_amd64.deb
-rw-r--r-- 1 root root 18M Apr 30 10:06 ejabberd_20.04-0_amd64.deb

Step 2: Install Ejabberd XMPP Server on Ubuntu 20.04

When the package has been downloaded, you can use the apt package manager to install it.

sudo apt install ./ejabberd_${EJ_VERSION}-0_amd64.deb

Confirm successful installation of Ejabberd XMPP Server on Ubuntu 20.04:

.....
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'ejabberd' instead of './ejabberd_20.04-0_amd64.deb'
The following NEW packages will be installed:
  ejabberd
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/18.5 MB of archives.
After this operation, 28.1 MB of additional disk space will be used.
Get:1 /root/ejabberd_20.04-0_amd64.deb ejabberd amd64 20.04-0 [18.5 MB]
Selecting previously unselected package ejabberd.
(Reading database ... 28241 files and directories currently installed.)
Preparing to unpack .../ejabberd_20.04-0_amd64.deb ...
Unpacking ejabberd (20.04-0) ...
Setting up ejabberd (20.04-0) ...

A number of actions will be performed by the installer:

  • Add ejabberd system user for application management
  • Create home directory for this system user – /opt/ejabberd
  • Start core ejabberd services
$ ls /opt/ejabberd
conf  database  logs
$ getent passwd ejabberd
ejabberd:x:998:998::/opt/ejabberd:/bin/sh

Step 3: Start ejabberd service on Ubuntu 20.04

Once the installation is done, you can then start ejabberd service on Ubuntu 20.04:

sudo cp $(sudo find / -name ejabberd.service) /etc/systemd/system

Reload systemd:

sudo systemctl daemon-reload

Start the service and enable it to start on boot:

sudo systemctl enable --now ejabberd

Ensure the service is started without any errors:

$ systemctl status ejabberd
● ejabberd.service - XMPP Server
     Loaded: loaded (/etc/systemd/system/ejabberd.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-05-23 11:31:59 CEST; 4s ago
    Process: 1478 ExecStart=/bin/sh -c /opt/ejabberd-20.04/bin/ejabberdctl start && /opt/ejabberd-20.04/bin/ejabberdctl started (code=exited, status=0/>
      Tasks: 23 (limit: 4567)
     Memory: 53.1M
     CGroup: /system.slice/ejabberd.service
             ├─1526 /opt/ejabberd-20.04/bin/epmd -daemon
             ├─1528 /opt/ejabberd-20.04/bin/beam.smp -K true -P 250000 -- -root /opt/ejabberd-20.04 -progname /opt/ejabberd-20.04/bin/erl -- -home /opt>
             ├─1539 erl_child_setup 65536
             └─1567 /opt/ejabberd-20.04/lib/os_mon-2.4.7/priv/bin/memsup

May 23 11:31:56 ubuntu systemd[1]: Starting XMPP Server...
May 23 11:31:59 ubuntu systemd[1]: Started XMPP Server.

Add ejabberdctl command location to your PATH

Locate ejabberdctl.

$ sudo find / -name ejabberdctl
/opt/ejabberd-20.04/bin/ejabberdctl

Add the path of to your .bashrc file.

$ vim ~/.bashrc

Set like below – but replace /opt/ejabberd-20.04/bin/ with your version path as found from find command:

PATH=$PATH:/opt/ejabberd-20.04/bin/

Source the file for the new path to be reflected:

source ~/.bashrc

Step 4: Add an Admin user to Ejabberd

You can add a user to ejabberd for your administrative purposes.

Syntax:

ejabberdctl register    

In my case, I’ll run the commands below:

# ejabberdctl register computingforgeeks $(hostname) StrongPassword
User [email protected] successfully registered

Where:

  • computingforgeeks is the name of the user to be created.
  • StrongPassword is the password associated to the user created.

Edit the ejabberd configuration file to give administration rights to the XMPP account you created.

User format:

"[email protected]"

Edit the acl section and add user.

$ sudo vim /opt/ejabberd/conf/ejabberd.yml
......

acl:
  local:
    user_regexp: ""
  loopback:
    ip:
      - 127.0.0.0/8
      - ::1/128
      - ::FFFF:127.0.0.1/128
  admin:
    user:
      - "[email protected]"
      - "[email protected]"

Restart Ejabberd service on Ubuntu:

sudo systemctl restart ejabberd

You can grant administrative privileges to as many XMPP accounts as you want, and also to accounts in other XMPP servers.

Step 5: Access ejabberd Web Admin

The Web Admin should be accessible on  http://server_ip_address_or_hostname:5280/admin/.

Check if the port is bound:

# ss -tunelp | grep 5280
tcp    LISTEN  0 5  *:5280   *:* users:(("beam.smp",pid=3124,fd=47)) uid:998 ino:66294 sk:8 v6only:0 

If you have ufw firewall, allow port 5280:

sudo ufw allow 5280

Open the ejabberd web URL in your browser. Input the username and password configured earlier.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/05/echo/install-ejabberd-ubuntu-01-1024×324.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

Access to the Ejabberd web console should be shown.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/05/echo/install-ejabberd-ubuntu-02-1024×263.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

You have installed Ejabberd XMPP server on Ubuntu 20.04 successfully.