How To Install ejabberd on a CentOS 5 and CentOS 6 VPS


Status: Deprecated

This article covers a version of CentOS that is no longer supported. If you are currently operating a server running CentOS 6, we highly recommend upgrading or migrating to a supported version of CentOS.

Reason: CentOS 6 reached end of life (EOL) on November 30th, 2020 and no longer receives security patches or updates. For this reason, this guide is no longer maintained.

See Instead:
This guide might still be useful as a reference, but may not work on other CentOS releases. If available, we strongly recommend using a guide written for the version of CentOS you are using.

About ejabberd

Ejabberd is a very simple, stable, and powerful XMPP server written in Erlang. This tutorial will guide you through the installation process and basic setup on a CentOS VPS.

Installing ejabberd

First we need to enable EPEL-Repository (EPEL = Extra Packages for Enterprise Linux) on your VPS. This is OS dependent:

On a CentOS 5.x VPS

wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
sudo rpm -Uvh epel-release-5*.rpm

On a CentOS 6.x VPS

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release-6*.rpm

For more information on EPEL, click here.

After enabling EPEL, we are ready to install ejabberd from the repositories. Do the following as root.

sudo yum install ejabberd

Set Hostname

The host name of your ejabberd service is set in the ejabberd config. Edit this with your preferred editor of your choice. In this example, I will be using vim.

sudo vim /etc/ejabberd/ejabberd.cfg 

Find the hostname section (Line #91. It should look something like:

%%%.   ================
%% hosts: Domains served by ejabberd.
%% You can define one or several, for example:
%% {hosts, ["example.net", "example.com", "example.org"]}.
{hosts, ["localhost"]}.

We want to add a new hostname. This is done by editing the last line in the snippet. If we would like to add example.com, it would look like this:

{hosts, ["localhost","example.com"]}.

Now that we have added your domain, save the file.

Start the Service

In order to make a new user, we first have to start the service.

sudo service ejabberd start

Make a User

To add a new user, run the following command:

ejabberdctl register username host password

Replace username, host and password with your own data. For example:

ejabberdctl register admin example.com superman

Admin privileges

Now have a user called admin with the password superman, we would like to give this user admin privileges.

We do this by editing the ejabberd configuration file like before. Find the admin user section (Line #369) in the config, which should look something like this:

%%%.   ====================

%% The 'admin' ACL grants administrative privileges to XMPP accounts.
%% You can put here as many accounts as you want.
%%{acl, admin, {user, "aleksey", "localhost"}}.
%%{acl, admin, {user, "ermine", "example.org"}}.

Now, add the following line. This will give our user admin rights.

{acl, admin, {user, "admin", "example.com"}}.

Remember to restart the ejabberd service every time we change something in the configuration file:

sudo service ejabberd restart

Web Interface

Ejabberd ships with a very nice and simple web-interface for statistics, configuration, etc.

You should spend some time browsing the web-interface to get familiar with it, it’s quite simple and shouldn’t take too long.

To open the web-interface, start a browser and go to:


You will need to authenticate with an admin user.

Adding New Users from Web Interface

When you first load up the admin interface, it should look like the following:

admin interface

Click Virtual hosts -> example.com -> Users.

Here you will be able to add new users, as shown below:

add user

Just click the “Add user” button and it will be created!

Setting Up a Client

In this section, I will be using Gajim. While there are many clients, the steps will be similar to the following with Gajim.

First, download Gajim, install it, and start the client.

We now have to add the newly created user. To do this, go to Edit->Accounts.

Click on the “Add” button, choose “I already have an account i want to use”, and press “Forward”.

Now enter the account information.

Tick the “Connect when I press Finish” box and click “Finish”. You have now connected to your own XMPP server.

<div class=“author”>Article Submitted by: Denhart</a></div>

Creative Commons License