Gentoo Wiki




You will likely have to edit a couple files before it will allow your to begin.

At the very least you should set these USE flags.

File: /etc/portage/package.use
net-im/ejabberd     ldap mod_irc mod_muc mod_pubsub -odbc ssl web
# or if you don't need irc/muc/pubsub support
net-im/ejabberd     -ldap -mod_irc -mod_muc -mod_pubsub -odbc ssl web
File: /etc/portage/package.keywords

Now just emerge. All dependencies will be built too.

emerge -va ejabberd

This took about ~15 minutes to compile

ejabberd Configuration

Below are a couple scripts which help with testing and configuring ejabberd. When using the Gentoo init scripts to start and stop ejabberd, it can make things difficult as many of the errors and issues are kept hidden in /dev/null. This doesn't help when having severe issues each time a configuration change is made. The configuration file would not parse properly, and crash with errors which unless you know erland should made no sense to you. After some searching a method was found that uses an XML file parsed through an XSLT processor and spits out a pretty well syntaxed ejabberd.cfg file.

You will also need two files from the site listed below: xml2erl.xsl ejabberd.cfg.xml

The default configuration settings in the xml file work ok and few changes like setting the correct hostname need to be made to have a working ejabberd server. The syntax of the xml file is also very easy to understand and made changes to.

Testing your ejabberd server

echo testing the ejabberd server
set -x
start-stop-daemon --start --chuid jabber:jabber \
--env HOME=/var/run/jabber \
--exec /usr/bin/beam \
--startas /usr/bin/ejabberd -- -noshell

This script is used to test changes made to the server configuration.

ejabberd.cfg script

# this script writes out the ejabberd.cfg file properly
# it uses XML to verify the validity of the file
echo ejabberd.cfg writer
set -x
xsltproc xml2erl.xsl /etc/jabber/ejabberd.cfg.xml > /etc/jabber/ejabberd.cfg

The script depends on xsltproc, so you'll need to install it first.

emerge -av libxslt

Starting/Stopping ejabberd

I'm just putting this here for the sake of it. Sometimes the init scripts do not work right properly. Starting ejabberd will work most times, and still give you [ !! ] and be working. Also because of this, issuing a stop will not work either, but instead you will have to kill the process manually.

/etc/init.d/ejabberd start
/etc/init.d/ejabberd stop
sudo killall -9 beam epmd

Creating ejabberd Admin users

Once you have the ejabberd running, it is a good idea to create your first user. Connect using your client, I prefer Gaim, and register a new JID. This will be your first user on the server, and also will be your admin account. Logout, and then stop the server.

If you're using the xml configuration remove the HTML escapes and change the JID to what you created.

  <acl name="admin"><user user=""/></acl>
  < !-- <acl name="admin"><user user=""/></acl> -- >

Reload the server, and now you have administrative rights which allow you to do special things.

SSL and ejabberd

The package now includes a nice script to make certificates, edit the [ req_dn ] section of /etc/jabber/ssl.cnf and then run

When specifying the SSL certificates in the cfg file or xml config, always remember use the the full path to the .pem certificate file. eg. /etc/jabber/.ssl.pem

Tips and Tricks

This guide has some creative ways to help you debug ejabberd (link broken, please fix) problems, however ejabberd can still be cryptic with its error messages (if it gives any). Here are some other tips that may help debug problems:

Sometimes after say changing the hostname of the machine your run ejabberd on, you will need to remove the contents of /var/spool/jabber.

optional DNS entries

simply cut and paste these into your zone file if you happen to run your own name server. 7200 IN   SRV     10 0 5222 7200 IN   SRV     10 0 5269

Links and Documentation

Retrieved from ""

Last modified: Wed, 20 Aug 2008 02:28:00 +0000 Hits: 17,185