Simon Coopey

Setting up an Openfire XMPP (Jabber) IM server on CentOS

This was one of the most popular posts on my old blog and I have kept it here as it gets dozens of hits every day. It is now a few years old, so information may be a little out-of-date. I may revisit this one day to update, and to add some graphics.

This is a mini-tutorial demonstrating how to set up a private IM/chat network on your CentOS Server- that you can use for your company, friends/family or community. We will be installing OpenFire from Ignite Realtime. At the end of this, you should be able to operate your own private-label IM network- your own MSN Messenger equivalent, but still allow users the option of talking to users of other IM clients, such as MSN Messenger, AIM/ICQ and Yahoo! Messenger.

Host Name

There are two important steps before installation can begin- firstly, you need to set up a host name for your chat server- things like jabber.yourdomain.com, chat.yourdomain.com or im.yourdomain.com are popular choices. This will for part of your users unique Jabber ID (JID) later on, so you might want to keep it short. How you go about this depends on whether you host DNS yourself or use a third-party. If you're attempting this sort of project, I'll assume you already know how to do this- if not consult support documentation or post in the comments below and I will try to help. Once changes have been made, flush the cache and reload the zone.
[root@yourserver ~]# rndc flush
[root@yoursever ~]# rndc reload

MySQL

Secondly, we want to create a database and user to store OpenFire's data. Your control panel may have a module installed for this, or you may have phpMyAdmin installed. OpenFire supports other types of database, but for simplicity's sake, install a MySQLdatabase. Create a database called 'openfire', 'jabber', 'chat' or something memorable and a user to accompany it. Grant the user full privileges over the database, and if you have the option reload/flush the privileges. Now, we can start the installation:

Installing OpenFire

You should download OpenFire only from the Ignite Realtime website, I installed version 3.6.4, but a newer version may be available so check first. Download the Openfire RPM via wget.
[root@yoursever ~]# wget -O openfire-3.6.4-1.i386.rpm http://www.igniterealtime.org/downloadServlet?filename=openfire/openfire-3.6.4-1.i386.rpm
You should get something like:
--11:10:13-- http://www.igniterealtime.org/downloadServlet?filename=openfire/openfire-3.6.4-1.i386.rpm
Resolving www.igniterealtime.org... 63.246.20.125
Connecting to www.igniterealtime.org|63.246.20.125|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 40451331 (39M) [application/x-rpm]
Saving to: `openfire-3.6.4-1.i386.rpm'

100%[=====================================================================>] 40,451,331   368K/s   in 1m 03s

11:11:45 (354 KB/s) - `openfire-3.6.4-1.i386.rpm' saved [40451331/40451331]

[root@yourserver~]#
Next RPM the file you have downloaded:
[root@yourserver ~]# rpm -ivh openfire-3.6.4-1.i386.rpm
Preparing...       ########################################### [100%]
1:openfire         ########################################### [100%]
Then start the OpenFire service, double-check it's running and set it to start automatically when the server boots:
[root@yourserver ~]# /etc/init.d/openfire start
Starting openfire:
[root@yourserver ~]# ps -ef | grep -i openfire
root      2508     1  0 07:35 pts/0    00:00:00 su -s /bin/sh -c /opt/openfire/jre/bin/java -server  -DopenfireHome=/opt/openfire -Dopenfire.lib.dir=/opt/openfire/lib -classpath "/opt/openfire/lib/startup.jar" -jar "/opt/openfire/lib/startup.jar" daemon
daemon    2511  2508 37 07:35 ?        00:00:07 /opt/openfire/jre/bin/java -server -DopenfireHome=/opt/openfire -Dopenfire.lib.dir=/opt/openfire/lib -classpath /opt/openfire/lib/startup.jar -jar /opt/openfire/lib/startup.jar
root      2526  2414  1 07:35 pts/0    00:00:00 grep -i openfire
[root@yourserver ~]# chkconfig --level 235 openfire on
[root@yourserver ~]#

Open OpenFire Ports

Next, we need to open the ports that OpenFire needs to communicate with the world outside your server. We need to open ports 9090, 9091, 5222 and 7777. Locate the file 'iptables' in /etc/sysconfig and add the following lines below other lines that start -A INPUT, but before any lines that start -A OUTPUT: **The first time I did this, I entered incorrect values and could not contact the OpenFire admin panel. Luckily, I found a how-to from 2007 by Tony Bhimani that set me straight.
-A INPUT -p tcp -i eth0 --dport 5222 -j ACCEPT
-A INPUT -p udp -i eth0 --dport 5222 -j ACCEPT
-A INPUT -p tcp -i eth0 --dport 7777 -j ACCEPT
-A INPUT -p udp -i eth0 --dport 7777 -j ACCEPT
-A INPUT -p tcp -i eth0 --dport 9090 -j ACCEPT
-A INPUT -p udp -i eth0 --dport 9090 -j ACCEPT
-A INPUT -p tcp -i eth0 --dport 9091 -j ACCEPT
-A INPUT -p udp -i eth0 --dport 9091 -j ACCEPT
Then reload iptables to enable these ports:
[root@yourserver ~]# iptables-restore < /etc/sysconfig/iptables
Restart OpenFire:
[root@yourserver ~]# service openfire restart
Shutting down openfire:
Starting openfire:
[root@yourserver ~]#

Configuration of Openfire

Open a browser and go to http://yourhostname.yourdomain.com:9090 or http://yourserveripaddress:9090 and follow the on-screen instructions, make sure you have the details for the host name and the MySQL database you created earlier as you'll need those now. At the end of the installation, you'll set your admin user name and password and then you're almost done. This is very important! After running the install you will have a log in screen, but don't do that just yet- go back to the command line and restart OpenFire again:
[root@yourserver ~]# service openfire restart
Shutting down openfire:
Starting openfire:
[root@yourserver ~]#
For some reason it chooses not to accept your admin password if you attempt to log in before a restart- this may be fixed for subsequent releases but as at 3.6.4 it is a minor nuisance. You can then return to http://jabber.yourdomain.com:9090 (or whatever you chose) and play with the admin settings. Once you have created users, it is just a matter of loading up your favourite Jabber client and chatting away. You get the cool JIDs of user@jabber.yourdomain.com and you don't have to worry about evil corporations logging your chats.

Getting your server to talk with MSN/ICQ/Facebook

To enable chat between users of your OpenFire server, and users of other services you need to install a 'transport'. A popular and very good one is Kraken by Daniel Henninger. Visit the site for the plugin and install instructions (it literally took 5 minutes to get talking with MSN and Yahoo!).

Setting up an Openfire XMPP (Jabber) IM server on CentOS

A mini-tutorial demonstrating how to set up a private IM/chat network on your CentOS Server using Ignite Realtime's Openfire XMPP server.

Posted: (last updated: 2014-03-05 14:52:50) by: Simon Coopey

This Page: http://simoncoopey.net/2010/openfire-install

Short URL: http://coopey.me/7-sPU



Home