Installing the Jabber Server

This chapter explains what you have to do to
obtain, install, configure, and start up a Jabber server of your own
with the minimum of fuss.

It's certainly possible to learn about the Jabber protocols and
technology and develop solutions using someone else's Jabber server, but
for real understanding and control, it's definitely worth setting up one
of your own. By installing and configuring a Jabber server, you will
gain a valuable insight into how it and its components work together.
Understanding how components are controlled and configured allows us to
build Jabber solutions in the context of the "big picture."

Installations of earlier versions (1.0, 1.2) of the Jabber server were
often complex affairs, and while the installation process has become
much more straightforward, some people still shrink back from installing
and configuring their own. This chapter shows how straightforward it is.

If you already have a server set up, you might want to skip this chapter
and go on to Chapter 4, where the configuration and system architecture
are explained in more detail.

Although the Jabber development platform is Linux, the Jabber server
will compile and run on many flavors of Unix, including FreeBSD,
Solaris, AIX, and IRIX.[1] Versions of the
C compiler and make utility from the GNU project (at http://www.gnu.org)
are recommended if you don't already have them installed.

The examples shown in this and other chapters are taken from Linux
platforms (various Slackware and Red Hat distributions with 2.2 and 2.4
kernel versions); consult your local documentation for equivalent
commands on your Unix OS.

The incarnation of the Jabber server at the time of writing is Version
1.4, more specifically 1.4.1. Version 1.4 represents a major advance in
the server code and brings increases in performance and reliability over
earlier versions. Jabber server Version 1.4.1 is the one we will obtain
and install here, and this will be used as the server for the recipes in
the rest of this book.

Downloading the Jabber Server

The Jabber server package can be
obtained from the Jabber project site, http://www.jabber.org; the 1.4.1
version is available in the downloads area:

you need to get a Jabber server up and running.[2]
Previous versions of the Jabber server came in multiple packages; it was
necessary to separately obtain and install GNU's portable threads
library (pth) and the asynchronous DNS package (ADNS), as well as
obtaining and installing various Jabber-specific libraries such as
libxode, libjabber, and libetherx. Now some of these libraries and
packages have become obsolete as far as the Jabber server is concerned
(ADNS and libetherx) and others have been combined into the main Jabber
server tarball.

If you don't want to compile the server yourself, you can also download
prebuilt binaries for some of the platforms already mentioned, from
http://download.jabber.org.

Installing the Server

Once you have downloaded the Jabber server
tarball, you need to unpack it, configure the build environment, and
compile the server. The general idea is that the Jabber server will be
compiled and run from wherever you decide to unpack it; that is, there
is no separate "install" step.

For this reason, and because it's also often useful to be able to
install and start up a different version of the Jabber server for
testing and comparisons, create a generic jabber directory somewhere
central but local, for example in /usr/local/:

| yak:/usr/local# mkdir jabber

The Jabber server does not need to be and should not be run as root;
so create a new user jabber (group jabber) to be used as the
Jabber server administrator and make that user the owner of the generic
Jabber server directory:

Running the Configure Server

Examining the contents of the
jabber-1.4.1 directory, we see the following files:

configure (the configuration script)

jabber.xml (the server configuration file)

Makefile (for compiling the Jabber server)

README (some basic instructions)

UPGRADE (information on upgrading from an earlier server version) as well as a number of directories that contain the source code.

The first step is to run the configure script:

| yak:~/jabber-1.4.1$ ./configure

to determine your platform's compiler settings.

If you want SSL support in the Jabber server, run the script with the
--enable-ssl switch:

| yak:~/jabber-1.4.1$ ./configure --enable-ssl

If you specified the --enable-ssl switch, the configure script looks for
your SSL installation and adds the appropriate compiler flags. If it
doesn't find your SSL installation, it says so and your Jabber server is
compiled without SSL support.

Next, it will try to determine whether you have pth installed and if so
will use the pth-config command to glean the extra compiler options for
building the Jabber server. pth is required, so if it isn't already
installed, it will be set up within your current jabber-1.4.1 directory
tree (as pth is included in the jabber-1.4.1.tar.gz tarball) and the
appropriate compiler options added.

If pth is set up during the course of running configure, you may see a
message: "Now please type 'make' to compile. Good luck.", which
comes at the end of the pth configure procedure; you can ignore this
because there is only one make step, for the Jabber server, that must be
carried out as we are merely preparing the pth build environment for
binding into the Jabber Server build.

Finally, after extra platform-specific compiler settings are determined,
a shell script to set the build environment variables is created with
the name platform-settings. This is used in the next step.

Running from the Build Environment?You may be wondering where
the make install step is—there isn't one. The Jabber server is run from
within its build environment. One of the reasons for this is that
additional components, such as transports, which may be installed at any
time after the basic server installation, must be compiled with
reference to various Jabber server header file information. One of the
simplest ways of making this happen is to have the source for those
components unpacked in a subdirectory within the jabber-1.4.1 directory
tree, and at compilation time component-level references to header files
at the Jabber server level can be made using relative directory names
that point back up the directory hierarchy.

Configuring the Jabber Server

The nature and behavior of a Jabber
server is controlled by the contents of a configuration file (with a
default name of jabber.xml), which you will find in the jabber-1.4.1
directory. As you can probably guess from the filename's extension, the
configuration is formatted in XML, which offers a very powerful way of
expressing the nature and features of your Jabber server and associated
services and components.

Details on how to navigate, interpret, and edit this configuration file
are given in Chapter 4; here we will just look at the basic settings
that can be modified before you start up the Jabber server.

For an experimental Jabber server (such as for the purposes of this
book), there isn't actually anything you need to change in the
configuration. The out-of-the-box configuration settings are pretty much
what we need in order to experiment with our recipes later in the book;
nevertheless, let's look at some of the settings you may wish to change
right now:

Server hostname

The <host/> parameter specifies the Jabber server's

hostname. As delivered, the jabber.xml configuration has this set to

localhost: :

|<host><jabberd:cmdline
flag="h">localhost</jabberd:cmdline></host>

You can change this to the name of your server hostname; in the case

of our examples, this would be yak. : The localhost setting occurs

elsewhere in the configuration too—as a literal in the welcome message

that is sent to users after a successful registration with the server.

You may wish to replace this occurrence of localhost; furthermore, you

will find other occurrences, but they are within sections of the

configuration that are commented out in the standard delivered version

of jabber.xml (specifically, administration JIDs and definitions for

various add-on agents and transports; we will cover these in the next

chapter). : One other place that localhost occurs is in the

<update/> section, which is explained next.

Server software update notification mechanism

The Jabber server development team offers a facility for servers to

check for updated versions of the Jabber server software. The facility

require vCard information to be entered when registering for a new
account, which means that an attempt to contact users.jabber.org
would be made the first time a user connects.

You may have noticed that the values for each of these two settings
(<host/> and <update/>) were wrapped in
another tag:

|<jabberd:cmdline flag="h">...</jabberd:cmdline>

This means that you can override the setting with a command-line switch
(or "flag"), in this case -h. So, in fact, you don't even need to modify
the jabber.xml configuration at all, if you specify your hostname when
you start the server up (the welcome message will not be changed, of
course).

Starting and Stopping the Jabber Server

At this stage, we have a
Jabber server with enough basic configuration to be able to start it up
and have it do something useful (like accept client connections). If
you're curious about the rest of the configuration you encountered while
editing the jabber.xml file, you can jump to Chapter 4. Otherwise, let's
start it up!

Starting the Server

The basic invocation looks like this:

| yak:~/jabber-1.4.1$ ./jabberd/jabberd

but if you haven't bothered to change localhost anywhere in the
configuration (as described earlier), you can use the -h switch to
specify the hostname:

| yak:~/jabber-1.4.1$ ./jabberd/jabberd -h yak

As it stands, there's a directive in the standard jabber.xml
configuration file that specifies that any server error messages are to
be written out to STDERR:

You won't lose the error messages—as you can see they're also written to
the error.log file.

Assuming you wish to free up the terminal session after starting the
server, you can send it to the background:

| yak:~/jabber-1.4.1$ ./jabberd/jabberd -h yak 2>/dev/null
&

Connecting a Client

Once the server is started, you're ready to
start up a client and make a connection. The thing to remember at this
point, when specifying which server to connect to, is to use the same
hostname as you specified in the <host/> part of the
configuration, described earlier in Section 3.3.

Note:

If your client supports the <alias/> mechanism,

described in Section 4.6.3 in Chapter 4, this may not be necessary.

Stopping the Server

To stop the server, just kill the processes,
and it will shut down:

| yak:~/jabber-1.4.1$ killall jabberd

or:

| yak:~/jabber-1.4.1$ kill `cat jabber.pid`

jabberd Command-Line Switches

We've seen the -h switch to
specify the host when starting the server up. There are other switches
available on the command line, too; they are listed in Table 3-1.

Command-line switches -

Switch

Relating to

Description

-c

Alternate configuration

Use this to specify an alternative configuration file if you don't want to use jabber.xml.

-D

Debugging info

Specifying this switch will cause (a large amount of) debugging information to be sent to STDERR.

-h

Hostname

The hostname of the Jabber server.

-H

Home folder

Used to specify "home" folder or directory.

-s

Spool area

The directory where the Jabber server stores data via the xdb_file module.

Yes, the list that it shows isn't complete. If the common switch -h were
present in the list, we could almost consider the unlisted switches as
undocumented, but it isn't present, so we won't.

Monitoring and Troubleshooting the Server

We've already seen a
glimpse of the configuration relating to logging of messages in the
previous section. As standard, the Jabber server configuration describes
two types of logging record and a recipient file for each type:

No XML Is Bad XML!If you don't use the -c switch to specify
which configuration file to use, the standard jabber.xml is used. If
that file can't be found, you get exactly the same error as if your
XML was not well-formed. You've been warned!