Despite the fact that the ejabber server is very popular, the use of the jabberd2 server turned out to be more comfortable for me. It’s easier to debug, its structure is clear, no need to download monster-like erlang. For small jabber servers, I find jabberd2 more than sufficient.

Download the latest package from https://jabberd2.org/

Unpack

We start with the following line ./ configure - enable- ldap - enable- mysql - enable- debug

Make

Make install

Do not forget to deliver the packages that you ask for.

So compiled.

The configuration files are located at / usr / local / etc

Editing sm.xml

< id> jabber. domain. local </ id> - server name of type jabber.google.com

... ..

<driver> mysql </driver>

...

Setting up a connection to the database

<mysql>

<! - Database server host and port ->

<host> localhost </host>

<port> 3306 </port>

<! - Database name ->

<dbname> jabberd2 </dbname>

<! - Database username and password ->

<user> name </user>

<pass> password </pass>

...

Configure LDAP server and authorization through LDAP

<ldapvcard>

<! - LDAP server host and port (default: 389) ->

<uri> ldap: // localhost </uri>

<! - DN to bind as for searches. If unspecified, the searches will be done anonymously. ->

<binddn> cn = root </binddn>

<bindpw> password </bindpw>

<! - see authreg.ldapfull int c2s.xml for description. ->

<type> ldap </type>

<! - LDAP attribute that holds the user ID (default: uid) ->

<uidattr> cn </uidattr>

<objectclass> person </objectclass>

<pwattr> userPassword </pwattr>

...

We determine where to look for our users and groups

<basedn realm = 'proxy.spii.rzdp'> o = Organization, dc = domain, dc = local </basedn>

<! - attribute that holds published group group or id,

jabberPublishedGroup if not set ->

<groupattr> jabberPublishedGroup </groupattr>

...

<! - base for searches for group id to group name mappings ->

<basedn realm = 'proxy.spii.rzdp'> o = Jabber, dc = samara, dc = en </basedn>

<! - what objectclass to search, jabberGroup by default ->

<objectclass> person </objectclass>

<! - what attribute to search, cn by default ->

<idattr> cn </idattr>

<! - attribute with text group name, description by default ->

<nameattr> cn </nameattr>

</mapped-groups>

Now edit c2s.xml

Note that this data must match in all 4 configuration files. It’s set up by default, but you never know what will make playful pens.

<! - IP / port the router is waiting for connections on ->

<ip> 127.0.0.1 </ip> <! - default: 127.0.0.1 ->

<port> 5347 </port> <! - default: 5347 ->

 

The following data is in this file. IP address and port on which the server will work

 

<id register-enable = 'true'> jabber.domain.local </id>

...

<ip> IP Address </ip>

<! - Port to bind to, or 0 to disable unencrypted access to the server (default: 5222) ->

<port> 5222 </port>

...

We indicate that we use an LDAP server for authorization

<authreg>

...

<! - Backend module to use ->

<module> ldap </module>

And its settings

<! - LDAPFULL module configuration ->

<ldapfull>

<! - LDAP server host and port (default: 389) ->

<uri> ldap: // localhost / </uri>

<binddn> cn = root </binddn>

<bindpw> password </bindpw>

<type> ldap </type>

<uidattr> cn </uidattr>

<objectclass> person </objectclass>

...

<pwscheme> bind </pwscheme>

...

<basedn> dc = domain, dc = local </basedn>

</ldapfull>

<ldap>

<host> jabber.domain.local </host>

<port> 389 </port>

<v3 />

<binddn> cn = root </binddn>

<bindpw> password </bindpw>

...

<! - LDAP attribute that holds the user ID (default: uid) ->

<uidattr> cn </uidattr>

<query> (& amp; (cn =% u) (objectClass = person)) </query>

<basedn> dc = domain, dc = local </basedn>

</ ldap>

 

That's the whole setup. The remaining files are left unchanged.

MySQL server setup

Now, since we indicated in the settings that we have a mysql base, apparently the structure of this base should be created

In the installation package in the tools folder there is a db-setup.mysql file

Run it

Mysql

. \ db-setup.mysql

If everything went without errors, then the database structure is created.

Now debugging

Checking is very simple. Each part can be launched separately.

For example, we want to check the operation of the sm module and run sm - D

We look at what errors and debug.

You can also run c2 s - D or router - D

After all the modules are debugged, you can run jabberd –D.

I would add another filter according to fail

 

jabberd - D | grep fail

 

And then when the setting gets even thinner I would write

 

jabberd - D | grep user

 

 

By the way I completely forgot to prompt to uncomment the line in the sm.xml

<auto-create />

 

Otherwise, you will get an interesting situation when there will be no authorization error, but you cannot enter the jabber online state by the client.

 

 

Everything, after that when you were able to connect to the jabber server by the client, you can write an init script. It looks like this for me.

 

#! / bin / bash

progs = "sm router c2s s2s"

progsPath = "/ usr / local / bin"

confPath = "/ usr / local / etc"

pidPath = "/ usr / local / lib / jabberd / pid"

logPath = "/ var / log / jabberd2"

 

case "$ 1" in

start)

echo "Initializing jabberd2 processes ..."

for prog in $ {progs}; do

if [$ (pidof -s $ {prog})]; then

echo -ne "\ tprocess [$ {prog}] already running"

sleep 1

continue

fi

echo -ne "\ tStarting $ {prog} ..."

rm -f $ {pidPath} / $ {prog} .pid

args = "- c $ {confPath} / $ {prog} .xml"

echo

sleep 1

done

;;

stop)

echo "Terminating jabberd2 processes ..."

for prog in $ {progs}; do

killall $ {prog}

# if [-f $ {pidPath} / $ {prog} .pid]; then

# echo -ne "\ tStopping $ {prog} ..."

# kill $ (cat $ {pidPath} / $ {prog} .pid)

# echo

# sleep 1

# fi

rm -f $ {pidPath} / $ {prog} .pid

done

;;

restart)

$ 0 stop

sleep 3

$ 0 start

;;

*)

echo "Usage: $ 0 {start | stop | restart}"

exit 1

;;

esac

exit 0

 

We put it in /etc/init.d/jabberd

Chmod 755 /etc/init.d/jabberd

update-rc.d jabberd defaults

update- rc. d jabberd enable

And now our jabber server starts automatically when the system reboots

 

 

Run /etc/init.d/jabberd start

  

 

Conference setup is even easier

Download https://download.gna.org/mu-conference/

 

make

After the assembly is completed, simply copy the resulting executable file to the appropriate location:

cp ./src/mu-conference / usr / local / bin

Copy the configuration file to the shared directory:

cp ./muc-default.xml /usr/local/etc/mu-conference.xml

 

Edit this file

 

<name> conference.domain.local </name> <! - the jid of your component ->

<host> conference.domain.local </host> <! - this should be the same as above ->

<ip> localhost </ip> <! - adress of the jabber server ->

<port> 5347 </port> <! - port used to connect the service to the jabber server ->

<secret> secret </secret> <! - secret shared with the jabber server ->

<spool> / var / spool / jabber-muc / rooms </spool> <! - directory containing the rooms data ->

<logdir> / var / log / jabberd2 </logdir> <! - directory containing the debug log (the file is called mu-conference.log) ->

<pidfile> /usr/local/lib/jabberd/pid/mu-conference.pid </pidfile> <! - file that will contain the PID of the process ->

 

We check the work

/ usr / local / bin / mu-conference -c / usr / local /etc/mu-conference.xml

 

If there are no mistakes, then we are well done

Writing an init script

#! / bin / bash

#export PATH = / sbin: / bin: / usr / sbin: / usr / local / bin

 

progPath = "/ usr / local / bin / mu-conference"

confPath = "/ usr / local / etc / mu-conference.xml"

pidPath = "/ usr / local / lib / jabberd / pid / mu-conference.pid"

 

case "$ 1" in

start)

echo "Initializing MU-Conference processes ..."

if [-f $ {pidPath}]; then

echo -ne "\ tMU-Conference already running"

exit 1

fi

echo -ne "\ tStarting MU-Conference ..."

rm -f $ {pidPath}

/ bin / su -s / bin / bash -l jabber -c "$ {progPath} -c $ {confPath} -B"> / dev / null

;;

stop)

echo "Terminating MU-Conference processes ..."

if [-f $ {pidPath}]; then

echo -ne "\ tStopping MU-Conference ..."

kill $ (cat $ {pidPath})

rm -f $ {pidPath}

fi

;;

restart)

$ 0 stop

sleep 3

$ 0 start

;;

*)

echo "Usage: $ 0 {start | stop | restart}"

exit 1

;;

esac

 

exit 0

 

Save it to /etc/init.d/mu-conference

Giving the rights to chmod 755 /etc/init.d/mu-conference

update-rc.d mu-conference defaults

update-rc.d mu-conference enable

run it

/etc/init.d/mu-conference start

Conference done

Copyright © 2024 AbakBot-online calculators. All Right Reserved. Author by Dmitry Varlamov