How to Running your own XMPP server on Debian or Ubuntu

This wiki page is shamefully pumped from http://doc.ubuntu-fr.org/jabberd2

Note that the jabberd2 package is only available under Debian in unstable.

If you haven’t already, add this line to your /etc/apt/sources.list

deb http://debian.mines.inpl-nancy.fr/debian/ unstable main contrib non-free

The purpose of this document is to provide a quick and easy way to install a jabberd2 server. For a more detailed configuration, refer to the official jabberd2 documentation which was used to create this page.

Prerequisites

To keep information related to users, you must have a database server installed (postgre, mysql…).

This should work for dapper and edgy (chances are it’ll still work for feisty).

To add a user to the server, run the following command as root:

# grou­padd jabber

# useradd -g jabber jabber

Then choose a password for this account using the following command:

# passwd jabber

After changing the password, we need to create a directory where the process will store its logs and pids.

To do this, run the following commands:

# mkdir -p /usr/local/var/jabberd/pid/

# mkdir /usr/local/var/jabberd/log/

Once the directories are created, let’s change the ownership of the directories so that the jabber user can write to them. Run the following commands:

# chown -R jabber:jabber /usr/local/var/jabberd/

Instal­la­tion du package jabberd2

# apt-get update && apt-get install jabberd2

You can also use Synaptic.

Via phpmyadmin, create a jabberd2 user and its jabberd2 table and note down its password, it will be used below.

(pour instal­ler phpmyad­min et la base MYSql: {CODE()}# apt-get install mysql-server phpmyad­min{CODE}

The script to create the tables:

CREATE DATABASE jabberd2;

USE jabberd2;

—c2s authen­ti­ca­tion/regis­tra­tion table

CREATE TABLE `authreg` (

`user­na­me` TEXT, KEY `user­na­me` (`user­na­me`(255)),

`realm` TINYTEXT, KEY `realm` (`realm`(255)),

`pass­word` TINYTEXT ) DEFAULT CHARSET=UTF8;

—Ses­sion mana­ger tables

—Active (seen) users

—Used by: core

CREATE TABLE `acti­ve` (

`col­lec­tion-owner` TEXT NOT NULL, KEY(`col­lec­tion-owner`(255)),

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`object-sequen­ce`),

`time` INT ) DEFAULT CHARSET=UTF8;

—Logout times

—Used by: mod_iq_last

CREATE TABLE `logout` (

`col­lec­tion-owner` TEXT NOT NULL, KEY(`col­lec­tion-owner`(255)),

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`object-sequen­ce`),

`time` INT ) DEFAULT CHARSET=UTF8;

—Ros­ter items

—Used by: mod_roster

CREATE TABLE `ros­ter-items` (

`col­lec­tion-owner` TEXT NOT NULL, KEY(`col­lec­tion-owner`(255)),

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`object-sequen­ce`),

`jid` TEXT,

`name` TEXT,

`to` TINYINT,

`from` TINYINT,

`ask` INT ) DEFAULT CHARSET=UTF8;

—Ros­ter groups

—Used by: mod_roster

CREATE TABLE `ros­ter-groups` (

`col­lec­tion-owner` TEXT NOT NULL, KEY(`col­lec­tion-owner`(255)),

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`object-sequen­ce`),

`jid` TEXT,

`group` TEXT ) DEFAULT CHARSET=UTF8;

—vCard (user profile infor­ma­tion)

—Used by: mod_iq_vcard

CREATE TABLE `vcard` (

`col­lec­tion-owner` VARCHAR(255) NOT NULL, KEY(`col­lec­tion-owner`(255)),

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`object-sequen­ce`),

`fn` VARCHAR(255),

`nick­na­me` VARCHAR(255),

`url` VARCHAR(255),

`tel` VARCHAR(255),

`email` VARCHAR(255),

`jab­be­rid` VARCHAR(3071),

`mai­ler` VARCHAR(1023),

`tit­le` VARCHAR(255),

`role` VARCHAR(255),

`bday` VARCHAR(255), # Shouldn’t this be a DATE?

`tz` VARCHAR(7),

`n-fami­ly` VARCHAR(255),

`n-given` VARCHAR(255),

`n-midd­le` VARCHAR(255),

`n-prefix` VARCHAR(255),

`n-suffix` VARCHAR(255),

`adr-street` VARCHAR(255),

`adr-extadd` VARCHAR(255),

`adr-pobox` VARCHAR(15),

`adr-loca­li­ty` VARCHAR(255),

`adr-region` VARCHAR(255),

`adr-pcode` VARCHAR(31),

`adr-coun­try` VARCHAR(63),

`geo-lat` VARCHAR (255),

`geo-lon` VARCHAR(255),

`org-orgna­me` VARCHAR(255),

`org-orgu­nit` VARCHAR(255),

`agent-extval` VARCHAR(255),

`sort-string` VARCHAR(255),

`desc` TEXT,

`note` TEXT,

`uid` VARCHAR(255),

`photo-type` VARCHAR(127),

`photo-binval` TEXT,

`photo-extval` VARCHAR(255),

`logo-type` VARCHAR(127),

`logo-binval` TEXT,

`logo-extval` VARCHAR(255),

`sound-phone­tic` VARCHAR(255),

`sound-binval` TEXT,

`sound-extval` VARCHAR(255),

`key-type` VARCHAR(127),

`key-cred` TEXT,

`rev` VARCHAR(255)

) DEFAULT CHARSET=UTF8;

—Offline message queue

—Used by: mod_offline

CREATE TABLE `queue` (

`col­lec­tion-owner` TEXT NOT NULL, KEY(`col­lec­tion-owner`(255)),

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`object-sequen­ce`),

`xml` MEDIUMTEXT ) DEFAULT CHARSET=UTF8;

—Pri­vate XML storage

—Used by: mod_iq_private

CREATE TABLE `pri­va­te` (

`col­lec­tion-owner` TEXT NOT NULL, KEY(`col­lec­tion-owner`(255)),

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`object-sequen­ce`),

`ns` TEXT,

`xml` MEDIUMTEXT ) DEFAULT CHARSET=UTF8;

—Mes­sage Of The Day (MOTD) messages (announ­ce­ments)

—Used by: mod_announce

CREATE TABLE `motd-messa­ge` (

`col­lec­tion-owner` TEXT NOT NULL, KEY(`col­lec­tion-owner`(255)),

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`object-sequen­ce`),

`xml` TEXT ) DEFAULT CHARSET=UTF8;

—Times of last MOTD message for each user

—Used by: mod_announce

CREATE TABLE `motd-times` (

`col­lec­tion-owner` TEXT NOT NULL, KEY(`col­lec­tion-owner`(255)),

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`object-sequen­ce`),

`time` INT ) DEFAULT CHARSET=UTF8;

—User-publi­shed disco­very items

—Used by: mod_disco_publish

CREATE TABLE `disco-items` (

`col­lec­tion-owner` TEXT NOT NULL, KEY(`col­lec­tion-owner`(255)),

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`object-sequen­ce`),

`jid` TEXT,

`name` TEXT,

`node` TEXT ) DEFAULT CHARSET=UTF8;

—Default privacy list

—Used by: mod_privacy

CREATE TABLE `pri­vacy-default` (

`col­lec­tion-owner` TEXT NOT NULL, KEY(`col­lec­tion-owner`(255)),

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`object-sequen­ce`),

`default` text ) DEFAULT CHARSET=UTF8;

—Pri­vacy lists

—Used by: mod_privacy

CREATE TABLE `pri­vacy-items` (

`col­lec­tion-owner` TEXT NOT NULL, KEY(`col­lec­tion-owner`(255)),

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`object-sequen­ce`),

`list` TEXT,

`type` TEXT,

`value` TEXT,

`deny` TINYINT,

`order` INT,

`blo­ck` INT ) DEFAULT CHARSET=UTF8;

—Vaca­tion settings

—Used by: mod_vaca­tion

CREATE TABLE `vaca­tion-settings` (

`col­lec­tion-owner` TEXT NOT NULL, KEY(`col­lec­tion-owner`(255)),

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`object-sequen­ce`),

`start` INT,

`end` INT,

`mes­sa­ge` TEXT ) DEFAULT CHARSET=UTF8;

—Users statuses

—Used by: mod_status

CREATE TABLE `sta­tus` (

`col­lec­tion-owner` TEXT NOT NULL,

`object-sequen­ce` BIGINT NOT NULL AUTO_INCREMENT, KEY(`object-sequen­ce`),

`sta­tus` TEXT NOT NULL,

`show` TEXT NOT NULL,

`last-login` INT DEFAULT ‘0’,

`last-logout` INT DEFAULT ‘0’,

`xml` TEXT);

Confi­gu­ra­tion

The server name in sm.xml and c2s.xml

Your server name must be filled in both /etc/jabberd2/sm.xml and /etc/jabberd2/c2s.xml.

Edit /etc/jabberd2/sm.xml:

# vi /etc/jabberd2/sm.xml

Fill in the id field of the sm section (~ line 1):

<!—Ses­sion mana­ger confi­gu­ra­tion—>

<sm>

<!—Our ID on the network. Users will have this as the domain part of

their JID. If you want your server to be acces­sible from other

Jabber servers, this ID must be resol­vable by DNS.s

(default: local­host)—>

<id>ma_machine.mon_domaine.com</id>

<!—Par exemple <id>marvin.asrall.iuta.univ-nancy2.fr</id>—>

Edit /etc/jabberd2/c2s.xml:

#vi /etc/jabberd2/c2s.xml

Fill in the local section id field (~ line 63):

<!—Local network confi­gu­ra­tion—>

<local>

<!—Who we iden­tify ourselves as. This should corres­pond to the

ID (host) that the session mana­ger thinks it is. You can

specify more than one to support virtual hosts, as long as you

have addi­tio­nal session mana­ger instances on the network to

handle those hosts. The realm attri­bute speci­fies the auth/reg

or SASL authen­ti­ca­tion realm for the host. If the attri­bute is

not speci­fied, the realm will be selec­ted by the SASL

mecha­nism, or will be the same as the ID itself. Be aware that

users are assi­gned to a realm, not a host, so two hosts in the

same realm will have the same users.

If no realm is speci­fied, it will be set to be the same as the

ID.—>

<id>ma_machine.mon_domaine.com</id>

As mentioned in the c2s.xml file, the server name (which is concatenated to the jabber id) must be resolvable by DNS (or via /etc/hosts) ❗ AVOID localhost, a jabber id is <name of ‘user>@<server name>, so when a client connects to your server it must have the correct server name and not localhost ❗

Mysql

Edit your /etc/jabberd2/c2s.xml again

<!—MySQL driver confi­gu­ra­tion—>

<mysql>

<!—Data­base server host and port—>

<host>local­host</host>

<port>3306</port>

<!—Data­base name—>

<dbname>jabberd2</dbname>

<!—Data­base user­name and pass­word—>

<user>jabberd2</user>

<pass>secret</pass>

You only need to change the host field if your database is not on the same machine as the jabberd2 server. If you are not using mysSQL’s default port (3306), you must modify the port field.

Of course the pass is not “secret” but corresponds to the password for the MySQL database of your jabberd2 user created at the beginning of the tutorial.

Jabberd2 is now configured. All you have to do is test your installation.

Installation testing

The jabberd2 server being launched as soon as the package is installed, it must be restarted in order to take the previous steps into account:

# /etc/init.d/jabberd2 restart

Or

# service jabberd2 restart

Then configure a jabber client (psi for example) from a local network machine to connect to your jabberd2 server. If that doesn’t work, good luck! Still go take a look in the logs (/var/log/jabber/).

If this operation succeeds and you want your server to be accessible from the internet, repeat the operation from a machine outside your network (or a live service like JWchat), if that does not work check your firewalls and that you are using an FQDN (try for example to resolve your DNS not one of the sites that offers this service)

In another post, I will tell you how to install the multi-user chat component.

EDIT  : Er, no, in fact I won’t explain how to install the multi-user chat, I struggled too much when I did it and anyway I forgot how to do it.

One comment

Leave a reply to How to Upgrade Debian to Debian Bullseye using the CLI – Free Code Tutorials Cancel reply