Create Instant Messaging Server with Jabberd2 and MySQL
Chatting server doesn't always Yahoo,Google or Microsoft. You can make chatting server base on open source software Jabberd2 and MySQL. In this tutorial i'll give you how to make instant messaging serverbase on jabber protocol with Jabberd2 as server and MySQL as jabber data storage place .For the installation make sure that you libdn version 0.3 or higher, OpenSSL verion 0.9 or higher and MySQL packet.
Jabberd2 Installation
After downloading the new and stabil jabberd2, go to directory where the jabberd2 placed.
1. Make new group and user call jabber
$ su
passwd :
# groupadd jabber
# useradd jabber
2. Make directory to save jabberd2 log files
# mkdir -p /usr/local/var/jabberd/log
3. Make directory to save jabberd2 PID files.
# mkdir -p /usr/local/var/jabberd/pid
4. Change log file and PID directory owner for user and group jabber
# chown -R jabber:jabber /usr/local/var/jabberd/
5. Extract jabberd file
# tar -zxf jabberd -2.0s10.tar.gz
6. Go to directory extract result and do configuration command
# cd jabber2-2.0s10
# ./configure --enable-idn --enable-mysql --enable-ssl
7. After configure finish, do build and installation
# make && make install
8. Change configuration files for root user and change file permission
# chown -R root:jabber /usr/local/etc/jabberd/*
# chmod 640 /usr/local/etc/jabberd/*
9. To make easy configuration setting, create symbolic link configuration jabberd2 directory to /etc
# ln -s /usr/local/etc/jabberd /etc/jabberd
Jabberd2 Configuration
Jabberd configuration files is file with extension.xml. For early step do configuration to sm.xml and c2s.xml
# vi /etc/jabberd/sm.xml
At part, insert hostname as identification for your jabber server
jabber.localhost.org
At part, on Router connection configuration, change 127.0.0.1 to your server ip address.EX:
192.168.0.1
5347
Save and now edit c2s.xml file,
Change IP address on Roter connection configuration with your server IP address.
192.168.0.1
5347
Then edit on Local network configuration by cahnge part with your hostname
jabber.localhost.org
MySQL Configuration
Execute MySQL setup script which locate in tools directory in source directory jabber. First change to tools directory
# cd tools
Make sure MySQL server service is running, and execute below command from console
mysql -u root -p
mysql> \. db -setup.mysql
mysql> GRANT select, insert, delete, update, ON jabber2.* to jabberd2@localhost IDENTIFIED by 'secret';
Jabberd2 user with password secret is the default.You can change it with your own user and password. If you choose to use default user and password, you dont have to edit sm.xml and c2s.xml. But if you use your own user and password do this :
localhost
3306
jabberd2
jabberd2
secret
On MySQL driver configuration change with your MySQL database user and with your MySQL database password.
user_db
pass_user_db
Server Test
Execute jabberd server with this command :
# su jabber
$ /usr/local/bin/jabberd &
Jabberd2 configuration with SSL Connection
First step is make self-signed SSL certificate
openssl req -new -x509 -newkey -rsa:1024 -days 3650 -keyout privkey.pem -out server.pem
Delete passphrase from your private key.
openssl rsa -in privatekey.pem -out privatekey.pem
Combine private key and public key in one file.
cat privatekey.pem >> server.pem
Delete your private key
rm privkey.pem
Remove server.pem file to /usr/local/etc/jabberd directory
# mv server.pem /usr/local/etc/jabberd/server.pem
Change owner and permission file for root user
# chown root:jabber /usr/local/etc/jabberd/server.pem
# chmod 640 /usr/local/etc/jabberd/server.pem
Configure SSL Certificate so can be use by Jabber client
SSL Key configuration for jabber client place in c2s.xml file. Edit location from your SSl Key. If you following steps above, uncomment file location on local network configuration session.
/usr/local/etc/jabberd/server.pem
Configure SSL Certificate Jabberd Between Component
Each of five Jabberd componen (router.xml,resolver.xml,s2s.xml,sm.xml and c2s.xml) have configuration for encrypted communication between component to jabberd router.So each component must be configured. Below is example configuration SSL Key certificate location for sm.xml. Same way can be done too to other files.
/usr/local/etc/jabberd/server.pem
After edited jabberd configuration file finish, restart your jabberd server. Now you can try from jabber client. In linux you can use Kopete, Gaim, Gabber or Psi while in window use Exodus or Psi. Enjoy !!!!
keyword : Linux Instant Messaging Server, Jabberd2, Jabberd2studio