Author: Mayank Sharma
The components you need include a Jabber server (I recommend jabberd2), a Jabber client or other IM client that understands the Jabber protocol, and, potentially, LibIDN, if it’s not included with your Linux distribution. LibIDN provides support for IETF Internationalized Domain Names. You also need a database (either MySQL, PostgreSQL, Berkeley DB) for storing jabberd data such as usernames and passwords.
First install LibIDN if you don’t have it. Download, unpack, and run the usual ./configure
, make
, su -
, and make install
commands. You can also install the jabberd2 server this way, but there are some configure options you should be aware of. When you invoke the ./configure
command without any parameters, the jabberd2 server is configured to install with support for IDN and SSL and use the MySQL database. If you want to change those settings, refer to the README file included in the jabberd2 package for a list of all the prefixes you can supply while configuring the server.
Even though I had MySQL properly installed, configured, and running, the jabberd2 configuration script exited with error: MySQL client libraries not found!
If you need to get around this problem, prefix your configure command with the statement: export LDFLAGS="-L/usr/local/lib -L/usr/lib/mysql";
. If you have let MySQL select its installation locations itself, this statement should work. If not, replace /usr/lib/mysql with the location of your MySQL libraries.
Once configuration is done, run make
, su -
, and make install
.
Setting up the server
Jabberd2 keeps its configuration files under the /usr/local/etc/jabberd directory and its binaries under /usr/local/bin in the sub-directories jabberd, c2s, resolver, router, s2s, and sm.
Before we configure jabberd2 we need to create a group and user for it. Never run a daemon as root. It’s a common practice to associate a daemon with a group and user. To do this, as root, run:
# groupadd jabber
# useradd -g jabber jabber
Next, create a directory for jabberd2 to store its PID:
# mkdir -p /usr/local/var/jabberd/pid/
and give it to jabberd2:
# chown -R jabber:jabber /usr/local/var/jabberd/pid/
Restrict access to the configuration files to the users root and jabber, as they contain passwords and other critical information:
# chown -R root:jabber /usr/local/etc/jabberd/*
# chmod -R 640 /usr/local/etc/jabberd/*
Before running the jabbered2 server, specify a MySQL database to store information. Change to the /tools subdirectory under the install directory and invoke MySQL to create the appropriate databases and tables:
# mysql -u root -p
Now create a jabberd2 MySQL user, assign it a password, and give it full permission to the jabberd2 database. Invoke MySQL:
# mysql -u root -p
At the MySQL prompt:
GRANT all ON jabberd2.* to jabberd2@localhost IDENTIFIED by password;
Replace password with a real password.
Check the file /etc/my.cnf to see what socket=
points to. If you installed MySQL from source it should point to /var/lib/mysql/mysql.sock. Jabberd2 connects to the MySQL socket at /tmp/mysql.sock, so create a symbolic link:
# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
Configure the server
In the final step of the process we need to tweak the configuration files. Change to the configuration directory /usr/local/etc/jabberd/ and open the file c2s.xml in a text editor. Keep your domain name and MySQL password (specified above with GRANT) handy.
Enter your domain name under the section “Local network configuration” between the id
tags. Also add the domain corresponding to the lo (127.0.0.1) IP address in the /etc/hosts file. Finally, scroll down to the section “MySQL driver configuration” and change the password. Save the file and exit.
Next, open the sm.xml file. In the first few lines, change the domain name here as well between the id
tags. Again look for the section “MySQL driver configuration” and change the password. Scroll to the “User option” section and change (or uncomment) the line:
<!- <auto-create/> -> to: <auto-create/>
Save and exit.
Those are the important settings. You should also change the default jabberd password. Once you have the setup working, play with the settings in these files. Every section is well commented.
Running the server
Log in as any user and change to the jabber user:
$ su
# su jabber
Run the jabberd server with the debug option:
$ cd /usr/local/bin/
$ ./jabberd -D
If you got no errors, you can begin adding users. If Jabberd crashes, you can refer to the Jabberd troubleshooting page.
To start adding users, log on to MySQL as the jabberd user and use the jabberd2 database:
mysql -u jabberd2 -p jabberd2
Create each user by inserting a row into the authreg table. Specify the username, realm (domain name), and password:
mysql> insert into authreg (username, realm, password) values (someusername, somedomain.something, somepassword);
Quit MySQL. Now it’s time for a test.
If you have ever used IM clients, this step should be familiar. Look at your IM client’s documentation on adding an account. If you are using an application such as Gaim that supports multiple protocols, remember to select the JABBER protocol from the list when adding a user. Enter your domain name as the server. Your username and password are what you specified while adding the user in the previous step. You should now be able to log in. Once you’re in, you should be able to add users to your IM list.
Conclusion
There’s more to Jabber than what I have described here. Jabber’s WikiPedia page is a nice place to start. If your interest goes beyond using Jabber as an IM, read its technical overview and learn how to develop on Jabber.
Many organizations can make good use of instant messaging, as part of their IT help desk, or as a tool for communicating with geographically spread out teams, for instance. A properly configured, secure, and high-speed enterprise IM application like Jabber can be just the presence management system they have been looking for.
Mayank Sharma is a freelance technology writer and FLOSS migration consultant in New Delhi, India.
Category:
- Enterprise Applications