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 22.04|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.
Before you perform the installation, set correct server hostname
sudo hostnamectl set-hostname ejabberd.example.com
sudo hostnamectl set-hostname ejabberd.example.com --static
logout
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 machine.
You may need to check the ejabberd downloads page for the latest version available. As of this article update, this is 21.07:
EJ_VERSION=23.01
wget https://static.process-one.net/ejabberd/downloads/${EJ_VERSION}/ejabberd_${EJ_VERSION}-1_amd64.deb
Confirm package is downloaded.
$ ls -lh ejabberd_${EJ_VERSION}-1_amd64.deb
-rw-rw-r--. 1 jkmutai jkmutai 15M Jan 17 18:13 ejabberd_23.01-1_amd64.deb
Step 2: Install Ejabberd XMPP Server
When the package has been downloaded, you can use the apt package manager to install it.
sudo apt install ./ejabberd_${EJ_VERSION}-1_amd64.deb
Confirm successful installation of Ejabberd XMPP Server on Ubuntu 22.04/20.04:
.....
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'ejabberd' instead of './ejabberd_21.07-0_amd64.deb'
The following packages were automatically installed and are no longer required:
libcamel-1.2-62 libextutils-pkgconfig-perl libgupnp-1.2-0 pkg-config
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
ejabberd
0 upgraded, 1 newly installed, 0 to remove and 108 not upgraded.
Need to get 0 B/18.8 MB of archives.
After this operation, 28.7 MB of additional disk space will be used.
Get:1 /home/jkmutai/ejabberd_21.07-0_amd64.deb ejabberd amd64 21.07-0 [18.8 MB]
Selecting previously unselected package ejabberd.
(Reading database ... 141300 files and directories currently installed.)
Preparing to unpack .../ejabberd_21.07-0_amd64.deb ...
Unpacking ejabberd (21.07-0) ...
Setting up ejabberd (21.07-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
Once the installation is done, you can then start ejabberd service on Ubuntu 22.04|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-21.07/bin/ejabberdctl start && /opt/ejabberd-21.07/bin/ejabberdctl started (code=exited, status=0/>
Tasks: 23 (limit: 4567)
Memory: 53.1M
CGroup: /system.slice/ejabberd.service
├─1526 /opt/ejabberd-21.07/bin/epmd -daemon
├─1528 /opt/ejabberd-21.07/bin/beam.smp -K true -P 250000 -- -root /opt/ejabberd-21.07 -progname /opt/ejabberd-21.07/bin/erl -- -home /opt>
├─1539 erl_child_setup 65536
└─1567 /opt/ejabberd-21.07/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-21.07/bin/ejabberdctl
Add the path of to your .bashrc
file.
sudo su -
vim ~/.bashrc
Set like below – but replace /opt/ejabberd-21.07/bin/ with your version path as found from find command:
PATH=$PATH:/opt/ejabberd-21.07/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 <username> <server_hostname> <user-password>
In my case, I’ll run the commands below:
# ejabberdctl register neveropen $(hostname) StrongPassword
User [email protected] successfully registered
Where:
- neveropen 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:
"username@servername"
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:
- "admin@ejabberd.example.com"
- "neveropen@ejabberd.example.com"
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.
Access to the Ejabberd web console should be shown.
You have installed Ejabberd XMPP server on Ubuntu 22.04|20.04 successfully.