Build your own instant messenger server Part 1

Many of you may be familiar with web messenger services such as gtalk or windows live (If not you have some explaining to do to the internet gods). I recently found myself in the position that I needed a service like windows live or gtalk but we did not want to be subject to them being the administrators, and just wanted it to work internally. After researching for a bit I decided to use Openfire as our server solution. Openfire is based on XMPP which will allow us to use different chat clients across different desktop platforms. I personally like to use Pidgin for my web messenger needs (Pidgin is just the client a server is still needed).

           Note: if you are looking for a SMS solution please check out my other guide here

Now that I have decided on what I want to use as my server, and which instant messaging client I would like to use, I need to get my hardware together. This turned out to be fairly simple because I have a Xenserver VM cluster at my disposal. I decided to use Linux as the base of the system because I don’t want to bring the server down for every patch Tuesday (plus, the added benefit of no added operating system cost).

Hardware:
Virtual machine or physical machine to setup the server on.

Software:
Centos 6.5 minimal install
Openfire server software

Goal:
Have an internal IM client solution similar to windows live or gtalk, allowing us to limit our direct human interaction with each other even if we are only 2ft away from each other (YAY IT to the rescue).

Lets Get Started

Install and setup MySQL

1. Log into your server as root
openfire01

2. run the following command

yum install mysql-server

openfireMySQLinstall

3. Answer yes to install MySQL server and its dependencies
openfireMySQLinstall2

4. Start MySQL server with the following command

service mysqld start

openfireMySQLinstall3

5. Let configure MySQL server by running the following command

/usr/bin/mysql_secure_installation

openfireMySQLinstall4

6. Just hit Enter when it asks for your current root password (we haven’t set one yet)
openfireMySQLinstall5

7. Answer Yes to set your root password for MySQL server
openfireMySQLinstall6

8. Answer Yes to remove anonymous users
openfireMySQLinstall7

9. Answer Yes to Disallow root login remotely
openfireMySQLinstall8

10. Answer Yes to remove test database and access to it
openfireMySQLinstall9

11. Answer Yes to Reload privilege tables
openfireMySQLinstall10

12. MySQL server is now installed and setup
openfireMySQLinstall11

13. Next we will allow MySQL to start after a reboot run the following command to do so:

chkconfig mysqld on

openfireMySQLinstall12

14. Next log into MySQl with the following command (enter your password when prompted):

mysql -u root -p

15. Lets create a database for Openfire to use with the following command:

CREATE DATABASE 'openfire';

16. Now lets create a user to use the database we just created with the following command:

CREATE USER 'openfire'@'localhost' IDENTIFIED BY 'userpassword';

17.Now lets grant the user openfire permissions to the openfire database and exit mysql:

GRANT USAGE ON *.* TO 'openfire'@'localhost' IDENTIFIED BY 'userpassword' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON `openfire`.* TO 'openfire'@'localhost';
FLUSH PRIVILEGES;
exit

The more steps will follow in Part 2

One comment on “Build your own instant messenger server Part 1
  1. Pingback: Citycorpse | Build your own instant messenger server Part 2

Leave a Reply

Your email address will not be published. Required fields are marked *