Ejabberd

From Gentoo Linux Wiki

Jump to: navigation, search

Ejabberd is a Jabber/XMMP instant messaging server written in erlang.

Contents

[edit] Installation

You will probably have to edit a couple files before it will allow you 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
net-im/ejabberd

Now just emerge. All dependencies will be built too.

emerge -va ejabberd

[edit] Configuration

Warning: In next section you'll find a simple script to test your configuration file. 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.

[edit] The erlang way

You can edit the /etc/jabber/ejabberd.cfg directly and it is pretty easy since the distributed config file gives many examples. The syntax is clear, but do mind to provide a dot '.', at the end of every line.

[edit] The XML way

It may occur that the configuration file does not parse properly, and crash with errors which unless you know Erlang will make no sense to you. A method was found that uses an XML file parsed through an XSLT processor and spits out a pretty well syntaxed ejabberd.cfg file. The following script will properly parse /etc/jabber/ejabberd.cfg.xml to write a well-formed, erlang config file.

You will also find two files from the site listed below: xml2erl.xsl, ejabberd.cfg.xml. The writecfg.sh script depends on xsltproc, so you'll need to install it first.

emerge -av libxslt

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.

File: writecfg.sh
#!/bin/sh
# writecfg.sh
# 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

[edit] The config file

You will need to provide your hostname to start with your ejabberd server, and then an admin user e.g, considering you are editing the erlang config file :

File: /etc/jabber/ejabberd.cfg
%%%   SERVED HOSTNAMES
{hosts, ["myhost.tld"]}.

%%%   ACCESS CONTROL LISTS
{acl, admin, {user, "admin_name", "myhost.tld"}}.

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

File: /etc/jabber/ejabberd.cfg.xml
/etc<acl name="admin"><user user="JID@localhost.net"/></acl>
 < !-- <acl name="admin"><user user="mysecondadmin@localhost.net"/></acl> -- >

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

You still need to register your admin user, see next section.

[edit] Testing your ejabberd server

File: testserver.sh
#!/bin/sh
# test.jabberserver.sh
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/sbin/ejabberd -- -noshell

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

[edit] 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

[edit] Registering your 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.

Another way to register them is using the control-script provided by gentoo :

ejabberdctl register username domainame password

[edit] 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 self-cert.sh. When specifying the SSL certificates in the cfg file or xml config, always remember use the full path to the .pem certificate file. eg. /etc/jabber/.ssl.pem

[edit] Tips and Tricks and errors

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

  • If you want to use a fully qualified hostname (ie domain.com not just domain) then you have to do more than just change the config file. If you just change the config file and start ejabberd won't start most of its services (do netstat -nlp|grep beam there should be atleast one running on 5222). To allow for FQDN you have to edit /usr/sbin/ejabberd and /usr/sbin/ejabberdctl with an editor and change -sname to -name
  • If you change the hostname you must also change ssl.pem if you haven't disabled this, otherwise it will fail when users try to connect and use TLS/SSL.
  • Sometimes after say changing the hostname of the machine your run ejabberd on, you will need to remove the contents of /var/spool/jabber.
  • If you get this while trying to stop your ejabberd daemon
* Stopping eJabberd ...
RPC failed on the node ejabberd@dev: nodedown [ !! ] 
Simply run
/etc/init.d/ejabberd zap

it will reset the status of your daemaon and you'll be able to reload your config.

  • This error; aborted,{no_exists,config} can occur after your servers named changed. You have to remove the files in /var/spool/jabber/*

[edit] optional DNS entries

simply cut and paste these into your zone file if you happen to run your own bind domain name server.

_xmpp-client._tcp.domain.com. 7200 IN   SRV     10 0 5222 xmpp.domain.com.
_xmpp-server._tcp.domain.com. 7200 IN   SRV     10 0 5269 xmpp.domain.com.

[edit] See also

[edit] External links and documentation

Personal tools