Configure ejabberd xmpp on ubuntu server part-2

configure ejabberd xmpp ubuntu server part 2

configure ejabberd xmpp ubuntu server part 1

In First Tutorial we have configure ejabberd XMPP with default menisa database . now in this tutorial i will explain how to configure ejabberd with MySql .

 

configure ejabberd xmpp ubuntu server part 2

configure ejabberd xmpp ubuntu server part 2

 

Step 1 :  Open etc/ejabberd/ejabberd.cfg file and comment following line :

{auth_method, internal}.

and add the following line in file :

{auth_method, odbc}.
{odbc_server, {mysql, “server”, “database name”, “username”, “password”}}.

here

  1. server : your mysql server ip
  2. user name and password : database access username and password .

Step 2 :

Now you need to configure mysql on server . so for that you need to install SVN on Ubuntu server by following command :
sudo apt-get install subversion

after installation of SVN you need to download MySql module.

  1. first create a directory  using mkdir command
  2. download following package  http://svn.process-one.net/ejabberd-modules/mysql/trunk/ by using below command : svn co http://svn.process-one.net/ejabberd-modules/mysql/trunk/
  3. after download  run /.build.sh c file . it will generate following beam file  in ebin folder

    mysql.beam

    mysql_auth.beam

    mysql_conn.beam

    mysql_recv.beam

  4. Please copy below file into  ejabberd ebin directory  /usr/lib/ejabberd/ebin this folder .
  5.  now open etc/ejabberd/ejabberd.cfg  file and do following changes
  • Change mod_last to mod_last_odbc to store the last seen date in MySQL.

  •  Change mod_offline to mod_offline_odbc to store offline messages in MySQL.

  • Change mod_roster to mod_roster_odbc to store contact lists in MySQL.

  •  Change mod_private to mod_private_odbc to store user private XML storage in MySQL.

  •   Change mod_privacy to mod_privacy_odbc to store user privacy lists in MySQL.

  •  Change mod_pubsub to mod_pubsub_odbc to store PubSub nodes, items and subscriptions in MySQL.

  •   Change mod_vcard to mod_vcard_odbc to store user description in MySQL.

Step 3 :

  1. Now Login in mySql Database and create a database “ejabberd
  2. Now download ejabberd MySql table schema folloing command   wget https://raw.githubusercontent.com/processone/ejabberd/master/sql/mysql.sql
  3. Now import this file in recently created “ejabberd” database.
  4. For installing mod_archive (for saving chat in DB)
    svn co https://svn.process-one.net/ejabberd-modules
    cd ejabberd-modules/mod_archive/trunk
    ./build.sh (If this step gives an error install erlang-nox package)
    copy ebin/* beam files in ejabberd ebin directory( /usr/lib/ejabberd/ebin)

     
  5. now go to this directory ejabberd-modules/mod_archive/trunk/src/ here you will find  this “mod_archive_odbc_mysql.sql” my sql file , you need to import this file in recently created database “ejabberd
  6. In /etc/ejabberd/ejabberd.cfg add mod_archive_odbc module
    {mod_archive_odbc, [{database_type, "mysql"},
    {default_auto_save, true},
    {enforce_default_auto_save, true},
    {default_expire, infinity},
    {enforce_min_expire, 0},
    {enforce_max_expire, infinity},
    {replication_expire, 31536000},
    {session_duration, 1800},
    {wipeout_interval, 86400}]},

    sudo service ejabberd restart

 

Now you have configured Ejabberd with MySql

if you need any assistance please comment ..

You may also like...

Creating a Shopify App using Laravel How to Create Custom WordPress Plugin? How to Build a Telegram Bot using PHP How to Convert Magento 2 into PWA?