Share on Social Media

In this guide, you will learn, how to install ejabberd on CentOS 7 or other Redhat based Linux distributions. #centlinux #linux #xmpp

What is ejabberd? :

ejabberd is a free and open source XMPP application server. ejabberd is developed by ProcessOne and distibuted under the terms of GNU GPL license. ejabberd is written in ERlang programming language. The name ejabberd is stands for Erlang Jabber Daemon.

As of year 2009, ejabberd is one of the most popular open source applications written in ERlang. Since the release of version 3 of ejabberd the versioning scheme was changed to reflect the dates as “Year.Month-Revision”. Latest stable release 19.05 is available through ejabberd official download page, whereas, we can download the latest in-development version of ejabberd from Github.

In this article, we will install ejabberd on CentOS 7 with MariaDB Server as backend database and then test the configurations using Spark IM Client.

This article provides the detail steps to install ejabberd on CentOS 7 but it does not provide the in-depth theoritical concepts of XMPP technology. Therefore, it is recommend that, you should read a good book on XMPP, like Xmpp: The Definitive Guide: Building Real-Time Applications With Jabber Technologies (PAID LINK) by O’Reilly Media to increase you understanding of XMPP protocol and related technologies.

Environment Specification:

We have provisioned a CentOS 7 virtual machine with following specifications:

  • Hostname: –
  • IP Address – /24
  • Operating System – CentOS 7.6

Install ejabberd Prerequisites:

Connect with using ssh as root user.

We will use MariaDB as the backend database for ejabberd software. Therefore, we are installing mariadb-server software package.

ejabberd also required glibc package to function properly.

We are installing both software packages using yum command.

# yum install -y mariadb-server glibc

Note: Please refer to our previous article, if you want to install the latest version of MariaDB on CentOS 7.

Enable and start MariaDB service.

# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/mariadb.service.
# systemctl start mariadb.service

Configure MariaDB instance as follows.

# mysql_secure_installation


In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Prerequisite software packages have been installed on our CentOS 7 server.

Install ejabberd on CentOS 7:

ejabberd Community Server 19.05 is released at the time of this writeup.

We can download Linux x86 64-bits RPM Package from ProcessOne’s ejabberd official download page.

# cd /tmp
# wget
--2019-06-04 18:29:05--
Reusing existing connection to
HTTP request sent, awaiting response... 200 OK
Length: 18799821 (18M) [application/x-redhat-package-manager]
Saving to: âdownloads-action.php?file=%2Fejabberd%2F19.05%2Fejabberd-19.05-0.x86_64.rpmâ

100%[======================================>] 18,799,821   228KB/s   in 97s

2019-06-04 18:30:42 (189 KB/s) - âdownloads-action.php?file=%2Fejabberd%2F19.05%2Fejabberd-19.05-0.x86_64.rpmâ saved [18799821/18799821]

Install ejabberd software package using rpm command.

# rpm -ivh ejabberd-19.05-0.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:ejabberd-19.05-0                 ################################# [100%]

ejabberd software has been installed on CentOS 7.

Configure ejabberd Backend Database:

We have already installed MariaDB Server.

Now, we are required to create a database and user for ejabberd.

# mysql -u root -p123
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE ejabberd;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT ALL ON ejabberd.* TO 'ejabberd'@'localhost' IDENTIFIED BY '123';
Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> EXIT;

Create the ejabberd database schema using the script, provided within ejabberd installation directory.

# mysql -u ejabberd -p123
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 4
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> USE ejabberd;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [ejabberd]> SOURCE /opt/ejabberd-19.05/lib/ejabberd-19.05/priv/sql/mysql.sql;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0

Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

Query OK, 0 rows affected (0.00 sec)

MariaDB [ejabberd]> exit

Our MariaDB database is successfully configured and ready to use by ejabberd software.

Now, its time to connect ejabberd with our MariaDB database.

ejabberd default internal database backend is Mnesia. But ejabberd XMPP server is very flexible and support MySQL, PostgreSQL and a few others as ejabberd database backend.

Add the following parameters in ejabberd.yml file to configure MariaDB database backend.

# cat >> /opt/ejabberd/conf/ejabberd.yml << EOF
> sql_type: mysql
> sql_server: "localhost"
> sql_database: "ejabberd"
> sql_username: "ejabberd"
> sql_password: "123"

ejabberd XMPP server has been configured to use MariaDB database backend.

Create Systemd Service for ejabberd:

Now, we need to create a systemd service for ejabberd.

There is a predefined systemd service for ejabberd XMPP server has been provided within ejabberd directory.

Copy the ejabberd.service to systemd services directory.

# cp /opt/ejabberd-19.05/bin/ejabberd.service /usr/lib/systemd/system/ejabberd.service

Enable and start ejabberd service.

# systemctl enable ejabberd.service
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/ejabberd.service.
# systemctl start ejabberd.service

ejabberd systemd service has been started.

If you encounter any error during startup of ejabberd.service, it is most probably due to the typostatic or syntax error in ejabberd.yml file.

Configure Firewall for ejabberd on CentOS 7:

Configure Linux Firewall to allow ejabberd following service ports.

# firewall-cmd --permanent --add-port={5280,5222}/tcp
# firewall-cmd --reload

Create an Admin User for ejabberd:

We can create users to access ejabberd Admin Console using ejabberdctl command.

# export PATH=$PATH:/opt/ejabberd-19.05/bin/
# ejabberdctl register admin 123
User successfully registered

We are using the predefined host in ejabberd.yml file.

If you are not happy with that, then you can add a custom host in ejabberd.yml file.

Browse URL in a client’s browser.

Login as user with 123 password.

ejabberd web login

After successful login, you will be at the dashboard of ejabberd Admin console.

ejabberd web Administration

Go to Virtual Hosts > > Users and add an IM (Instant Messaging) user as follows.

ejabberd web users

Test ejabberd Server using an IM client:

To test our ejabberd XMPP server, we need an IM (Instant Messaging) client software.

There are many free IM clients are available over the Internet. But we are using Spark IM client for MS Windows.

Download Spark client from Ignite Realtime Official Website.

Spark installation is pretty straight forward, thus we are skipping the installation steps.

After Spark installation, run it using the shortcut on the Desktop.

The Spark software will display a login prompt.

Spark IM Client Login 1

But before login, we have to do some settings therein.

Click on Advanced settings.

Spark IM Client Settings

Adjust the settings as per the above screenshot.

Click on Ok.

Spark IM Client Login 2

We are again at the Login screen.

Login as ahmer user.

Spark IM Online Clients

We are successfully logged in to ejabberd XMPP Server.


We have successfully install ejabberd XMPP server on CentOS 7 and tested it using Spark IM client.

Leave a Reply

Your email address will not be published. Required fields are marked *