Site layout and content is being updated.
Linux Related -> Tutorials -> How to setup a Jabber serverHow to setup a Jabber server
Unless you have been living under a rock for the past few years you must have heard about instant messaging and how its changed the world of communications over the internet. According to http://www.webopedia.com Instant Messaging (IM) is a service that alerts users when their friends or colleagues are on line and allows them to communicate with them in real time through private online chat areas. Some of the most popular IM services are AOL IM and MSN Messenger. Unfortunately most of the publicly available servers use proprietary protocols that only allow you to communicate with users on the same system. These systems are not compatible with each other and can't be accessed from other clients.
Jabber is an open source implementation of the IM server that aims to change this. It uses streaming XML protocols that are free, open and public. These protocols have been formalized by the Internet Engineering Task Force (IETF) as the approved instant messaging and presence technology under the name of XMPP. The first Jabber technologies were developed in 1998 by Jeremie Miller and is now used on thousands of servers world-wide to enable millions of users to communicate with each other.
The biggest advantage of the Jabber server when compared with commercial IM servers is that since its open source anyone can run a Jabber server and it can be restricted to a specific community like a company work force or a group of friends. In this article I will document the steps I took to setup a Jabber server and how I managed to overcome the difficulties I faced. Hopefully this would make it easier for you to setup a Jabber server.
Created by: Suramya Tomar
Last updated: 14th Febuary 2005
This document is Copyright © 10th July 2004, Rubix Information Technologies, Inc
It is released to the public under the Creative Commons Attribution-ShareAlike 1.0 License
You are free:
- To copy, distribute, display, and perform the work
- To make derivative works
- To make commercial use of the work
Under the following conditions:
Attribution. You must give the original author credit.
Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.
- For any reuse or distribution, you must make clear to others the license terms of this work.
- Any of these conditions can be waived if you get permission from the author.
Use the information in this document at your own risk. I disavow any potential liability for the contents of this document. Use of the concepts, examples, and/or other content of this document is entirely at your own risk. They worked on my system but it doesn't necessarily mean that it would be safe to do the same on your system.
All copyrights are owned by their owners, unless specifically noted otherwise. Use of a term in this document should not be regarded as affecting the validity of any trademark or service mark.
You are strongly recommended to take a backup of your system before performing any of the actions listed in this document .
In this section I have the pleasure of acknowledging the following people without whose input this would have never seen the light of the day:
- The creators and maintainers of http://www.jabber.com from where I compiled most of this information
- Alf Eaton for posting the steps he took to get the Jabber conference feature working
- Renny Koshy for letting me try setting up a Jabber server on his machine
- Matt Hoskins and Kevin Walsh, for getting me interested in linux in the first place.
- My friends and family, for bearing with me when I was compiling this document
Before we can compile the server we need make some changes on the system we will be installing the server on to make it more secure when running the Jabberd server. The first thing we have to do is to create a new user so that the Jabberd server process is not run as root. This is highly recommended 'cause running server processes as root is a pretty bad idea.
Now, you might be wondering why that's the case. Right? Well imagine this scenario: A buffer overflow flaw is discovered in the Jabberd server code and before a fix for it has been written a script-kiddy who has hated you since you stole his place in the 5th grade cafeteria finds out that you are running a version of the server that is vulnerable to the attack and decides to hack you. Now if you are running the server as root he would have you in his mercy as he has full control of the server and he can do whatever he wants with it. On the other hand if you were running it as another user he would still have to jump through a lot of hoops to get root access and hopefully he would set of some kind of alarm before he gets it. Allowing you to catch him. Convinced yet? No? Well its your funeral...
To add a user to the server run the following command as root:
Then choose a password for the account by running the following command:
After changing the password we need to create a directory where the jabberd process with store its logs and pid's. You do it by running the following commands:
mkdir -p /usr/local/var/jabberd/pid/
mkdir -p /usr/local/var/jabberd/log/
Once the directories are created we need change the ownership of the directories so that the user jabber can write
to them. We do this by running the following commands:
chown -R jabber:jabber /usr/local/var/jabberd/pid/
chown -R jabber:jabber /usr/local/var/jabberd/log
Since Jabber is an Open source project there are multiple implementations of the Jabber server. A list of some of the servers is available at: http://www.jabber.org/software/servers.shtml. I decided to use the Jabberd 2.x implementation of the server as I already had the source for the server on my computer and it wasn't possible to download another server source due to the recent hack of the Jabber Studio servers and the subsequent shut down of the download section of the site while they figured out what was going on.
Hopefully by the time you read this the server should be back to normal and you will be able to download the latest version of the server from their site. If that's not the case you can download jabberd Ver 2.0s2 from here
First thing we have to do after we download the source is to uncompress it by issuing the following command:
tar -zxf jabberd-2.0s2.tar.gz
Then we change our current working directory to the jabberd source directory by issuing the following command:
The jabberd server has a lot of configuration options that can be set during the initial configuration. To see a list of all the options available run the following command:
I decided to go with the default settings so I used the following command to configure the install process:
Once the configure script has finished running without giving any errors we can go ahead and compile the program by issuing the following command:
and once this is done we install the server by running the following command as root:
By default jabberd uses MySQL to store the user data. So now we need to setup a new MySQL database that jabberd can
access. There is a script in the tools directory that makes this really easy to do. To run the script issue the following
mysql -u root -p < tools/db-setup.mysql
Enter the mysql root password when you are prompted for it. This script creates a new database and populates it with tables that the jabberd server requires. Once the script finishes running we need to create a user
called jabberd2 in MySQL to allow jabberd to manipulate the database. This is done by issuing the following command:
mysql -u root -p
Now enter the root password when you are prompted for it and you will get the MySQL command prompt. At this prompt
enter the following command:
GRANT select,insert,delete,update ON jabberd2.* to jabberd2 at localhost IDENTIFIED by 'examplepassword';
replacing examplepassword with a password of your choice. Once you run this command type
to exit the program. This finishes the installation of the jabberd server. Now we need to customize the server for our use and we will cover that in the next section
To customize the server we first need to change to the jabberd directory by running the following command:
cd /usr/local/etc/jabberd/. Then we want to edit the sm.xml file so we follow the following steps as root:
- Open sm.xml in your favorite text editor
- Change the ID on the network from localhost to
jabber.yoursite.com(Make sure that jabber.yoursite.com resolves)
- Scroll down to the User Options and uncomment the
<auto-create/>tag. This allows users that are not registered on the server to register themselves.
- If you want to have a predefined userlist to populate all new users scroll to the the end of the file and uncomment
<roster>/usr/local/etc/jabberd/templates/roster.xml</roster>. We will cover the contents of the roster.xml in a few mins.
Once we are done editing save sm.xml and exit the editor. Now we need to customize c2s.xml so follow the following steps as root:
c2s.xmlin your favorite text editor
- Scroll to the
'Local network configuration'section and change the <id> from localhost to jabber.yoursite.com
- Save and exit
This completes the configuration of the jabberd server. This gives us a basic jabber server that allows users to register themselves and chat with each other. However if we want to have the ability to create chat rooms we need to install an additional software called mu-conference. We will cover the installation of mu-conference momenterially.
jabberd gives us the ability to create a template buddy list so that each new user has a default buddy list. This is very useful in environments where the administrator wants to make sure each user has all the important people in their buddy list without spending a lot of time adding each user manually.
The template file is located in the templates directory and is called
roster.xml. The file has the following format:
<item name=Buddy Name jid=JID@Host.domain subscription=both><group>BuddyGroup</group></item>
To add new users we need to uncomment the <item name> tag and add a new line for each user. For example if you
wanted to add me to the default roster and my JID (Jabber ID) was email@example.com the entry for my name would
look like this:
<item name='Suramya' firstname.lastname@example.org' subscription='both'><group>Support</group></item>
The group field tells the client under which group the entry is supposed to be stored. In this case Suramya is being stored under the Support group. All entries need to be enclosed within the <query> </query> tag, so the complete file with one user would look something like:
<item name=Suramya email@example.com subscription=both><group>Support</group></item>
Before we can install mu-server we need to install the Jabber Component Runtime(JCR) which is available for download at: http://jabber.terrapin.com/JCR/jcr-0.1.2.tar.gz. To download and install JCR follow these steps:
- Download the source using:
- Uncompress the archive using:
tar -zxf jcr-0.1.2.tar.gz
- Change to the jcr source directory using:
- Compile jcr by running:
Once jcr finishes compiling we can proceed with the installation of mu-conference by following these steps:
- Download the mu-conference source in the jcr directory from here
- Uncompress the archive using:
tar -zxf mu-conference-0.6.0.tar.gz
- Copy main.c to the src directory using the following command:
cp src/main.c mu-conference-0.6.0/src
- Copy jcomp.mk to the src directory using the following command:
cp src/jcomp.mk mu-conference-0.6.0/src
- Change to the mu-conference source directory using:
- Compile mu-conference using:
make -f jcomp.m
- Copy the mu-conference executable created to the jabberd folder using:
cp mu-conference /usr/local/bin
- Copy the Configuration file to jabberd configuration folder using:
cp ../muc-jcr.xml /usr/local/etc/jabberd/
Now we have to customize mu-conference by editing
To customize the conference follow these steps:
muc-jcr.xmlin your favorite text editor
- Change the name and host fields to
- Add <user>jabberd</user> before the secret line
- Change the spool, logdir and pidfile lines to:
- Create the spool directory using:
mkdir -p /usr/local/var/jabberd/spool/
This finishes the configuration of the mu-conference server and we are ready to run the server
To run the server run the following commands:
- Switch to the jabber user using:
- Start the jabberd server process using:
- Start the mu-conference server using:
/usr/local/bin/mu-conference -c /etc/jabberd/muc-jcr.xml &
By now I have hopefully saved you a lot of trouble by telling you how to setup a jabber server quickly and easily. If you think this document helped you or you have some comments or questions about this please feel free to Contact Me and let me know. However I must warn you that I am a somewhat lazy person who might take a little while before replying to your emails.
Thanks for your time
- Suramya Tomar
14th Feb 2005