Lately I switched from a binary Ejabberd package to a self-built version of Ejabberd on my XMPP server trashserver.net. This was done mainly because the “Debian Backports” repository did not offer the version of Ejabberd that I urgently needed. While the repo was stuck at 20.02, I wanted to provide the users 20.04 to be able to drastically improve the user experience during video calls.
The Debian project’s Ejabberd maintainer was not sure about the final release date of Ejabberd 20.04 in the Backports repo, so I chose for compiling Ejabberd myself to get my hands on the latest version as soon as possible. That would give me the following benefits:
- Ejabberd can be updated independently from any Debian packaging processes / workflows
- I’m able to use the latest patches / updates on GitHub
As soon as the build time package dependencies are clear, the build process it pretty straight forward. By the way: I’m using Ejabberd with PostgreSQL as a backend. The compile process will vary a little bit if you’re utilizing Ejabberd’s Mnesia DB or MySQL.
Preparing the build environment
You will need Debian’s official “Buster Backports” repository for some erlang dependencies that we’re going to install. Instructions for activating the Backports can be found here:
Then install the build dependencies:
apt update apt install \ git \ build-essential \ automake \ libssl-dev \ libexpat-dev \ libyaml-dev \ libz-dev apt install -t buster-backports \ erlang-base \ erlang-dev \ erlang-p1-pgsql \ erlang-parsetools \ erlang-os-mon \ erlang-eunit \ erlang-p1-yconf
Download the Ejabberd source code to your home directory and select the latest version (at the time of writing:
git clone git://github.com/processone/ejabberd.git ejabberd cd ejabberd git checkout 20.04
Configuring and running the build process
Now configure the build as you need it. I’m enabling the PostgreSQL support here. You might want to enable MySQL, instead.
./configure --help will show you all the available configuration flags that might be interesting for your environment.
./autogen.sh ./configure \ --prefix= \ --exec-prefix=/usr/ \ --enable-user=ejabberd \ --enable-pgsql \ --enable-stun \ --enable-zlib \ --enable-new-sql-schema
Now build Ejabberd!
The build process will take some time, but soon you should be presented a terminal windows with no error messages in it.
It is now time to install Ejabberd on the system. Before to that, a new System user for ejabberd is created:
adduser --system --group --home /var/lib/ejabberd ejabberd
You can now type
to install all the files at the right location.
The make process did also create a Systemd service file. We’re installing it to be able to control the XMPP server via Systemd:
cp ejabberd.service /etc/systemd/system/ systemctl daemon-reload systemctl enable ejabberd
As soon as your server is configured in
/etc/ejabberd/ejabberd.yml, start your server using
systemctl start ejabberd
The log file in
/var/log/ejabberd/ejabberd.log should give you valuable information on the startup of Ejabberd. If you experience any problems that you cannot solve yourself, consider checking out the official Ejabberd (XMPP) chat room at:
In case you need an example configuration for inspiration, check out https://github.com/ThomasLeister/trashserver.net-xmpp
Before updating Ejabberd, make sure you’ve carefully read the release notes for the corresponding version on the ProcessOne blog! https://www.process-one.net/blog/
The release notes contain information about the changes and provide instructions if manual intervention is required, e.g. for database schema updates.
For usual updates, which do not require any database updates, the update procedure looks similar to this (e.g. for version 21.12):
cd ejabberd git checkout 21.12
./autogen.sh ./configure \ --prefix= \ --exec-prefix=/usr/ \ --enable-user=ejabberd \ --enable-pgsql \ --enable-stun \ --enable-zlib \ --enable-new-sql-schema make update make
Stop running Ejabberd instance:
systemctl stop ejabberd
Replace Ejabberd by new version:
Add updated Systemd service file:
cp ejabberd.service /etc/systemd/system/ systemctl daemon-reload
Start new Ejabberd version:
systemctl start ejabberd
… and observe error log:
tail -f /var/log/ejabberd/error.log
If Cookie errors appear, set the permissions correctly:
chown ejabberd /var/lib/ejabberd/.erlang.cookie chmod 600 /var/lib/ejabberd/.erlang.cookie