# Jabberd2 Server Setup Howto

## batfoot

Hi all. 

Here is a working howto on how to setup a base jabberd2 server on Gentoo.

1. Install OpenSSL

emerge openssl

2. Install Libidn

emerge libidn

3. Install MySQL

emerge mysql

4. Create jabber user and group.

groupadd jabber

useradd -g jabber jabber

5. Create PID file directory & set correct permissions.

mkdir -p /usr/local/var/jabberd/pid/

chown -R jabber:jabber /usr/local/var/jabberd/pid/

6. Create Log file directory & set correct permissions.

mkdir /usr/local/var/jabberd/log/

chown -R jabber:jabber /usr/local/var/jabberd/log/

7. Create initial MySQL database.

/usr/bin/mysql_install_db

8. Start MySQL.

/etc/init.d/mysql start

9. Setup MySQL password.

/usr/bin/mysqladmin -u root password 'newpassword'

10. Set MySQL to start at boot time.

rc-update add mysql default

*** At this point MySQL should be set up and ready to use. You can reboot here to ensure MySQL starts up as it should if you like.

*** There is an ebuild for jabberd1.4xx. I have had this working by just emerging the package. However if you 

do this you will need to add USE="-ipv6" to your /etc/make.conf file. Unless of course you are using ipv6 in which

case you won't need to worry about it.

Installing Jabberd2. 

*** I have used jabberd-2.0s8 as the example below as it is the latest version that is on their website, and

also the version that I have installed.

11. Download jabberd2 from http://jabberd.jabberstudio.org/2/   to your /root folder. Then enter your /root folder.

cd /root

12. Extract the jabberd package.

tar -zxvf jabberd-2.0s8.tar.gz

13. Enter the newly created folder.

cd jabberd-2.0s8

14. Configure the source code to run with your setup.

./configure --enable-mysql --enable-openssl --enable-idn

15. Compile the source code.

make

16. Install the jabberd package.

make install

17. Set the ownership of the jabber configuration files.

chown -R root:jabber /usr/local/etc/jabberd/*

18. Set the permissions of the jabber configuration files.

chmod -R 640 /usr/local/etc/jabberd/*

19. Enter the jabber configuration folder. 

cd /usr/local/etc/jabberd/

20. Setup your hostname in both sm.xml and c2s.xml under the <id> tags.

 In sm.xml :

      <!-- Session manager configuration -->

      <sm>

        <!-- Our ID on the network. Users will have this as the domain part of

             their JID. If you want your server to be accessible from other

             Jabber servers, this ID must be resolvable by DNS.s

             (default: localhost) -->

        <id>somemachine.somedomain.com</id>    

In c2s.xml :

      <!-- Local network configuration -->

      <local>

        <!-- Who we identify ourselves as. This should correspond to the

             ID (host) that the session manager thinks it is. You can

             specify more than one to support virtual hosts, as long as you

             have additional session manager instances on the network to

             handle those hosts. The realm attribute specifies the auth/reg

             or SASL authentication realm for the host. If the attribute is

             not specified, the realm will be selected by the SASL

             mechanism, or will be the same as the ID itself. Be aware that

             users are assigned to a realm, not a host, so two hosts in the

             same realm will have the same users.

             If no realm is specified, it will be set to be the same as the

             ID. -->

        <id>somemachine.somedomain.com</id>        

21. Enter your jabberd/tools source code folder again.

cd /root/jabberd-2.0s8/tools

22. Provision jabber for MySQL (MySQL should be up and running at this point).

mysql -u root -p

mysql>\. db-setup.mysql

23. Set password for your jabberd mysql user.

GRANT select,insert,delete,update ON jabberd2.* 

to jabberd2@localhost IDENTIFIED by 'newpassword';

quit

24. Enter the jabberd configuration folder.

cd /usr/local/etc/jabberd

25. Configure jabberd for storage with MySQL.

In sm.xml ensure that mysql is set in the <driver> tag.

<!-- Storage database configuration -->

        <storage>

          <!-- By default, we use the MySQL driver for all storage -->

          <driver>mysql</driver>     

26. Setup the MySQL password that you created in step 23.

In sm.xml replace 'secret' with your password.

<!-- MySQL driver configuration -->

      <mysql>

        <!-- Database server host and port -->

        <host>localhost</host>

        <port>3306</port>

        <!-- Database name -->

        <dbname>jabberd2</dbname>

        <!-- Database username and password -->

        <user>jabberd2</user>

        <pass>secret</pass>

        <!-- Transaction support. If this is commented out, transactions

             will be disabled. This might make database accesses faster,

             but data may be lost if jabberd crashes.

             This will need to be disabled if you are using a MySQL

             earlier than v3.23.xx, as transaction support did not appear

             until this version. -->

        <transactions/>

      </mysql>

27. Configure jabberd for authentication with MySQL.

In c2s.xml ensure that mysql is set in the <module> tag.

<!-- Authentication/registration database configuration -->

      <authreg>

        <!-- Backend module to use -->

        <module>mysql</module>      

28. Setup the MySQL password that you created in step 23, this time in c2s.xml.

In c2s.xml replace 'secret' with your mysql password in the <pass> tags.

<!-- MySQL module configuration -->

      <mysql>

        <!-- Database server host and port -->

        <host>localhost</host>

        <port>3306</port>

        <!-- Database name -->

        <dbname>jabberd2</dbname>

        <!-- Database username and password -->

        <user>jabberd2</user>

        <pass>secret</pass>

      </mysql>

29. Start the jabberd server.

/usr/local/bin/jabberd

OK... you're all done. All you need to do now is install client software on the client workstations. I personally use PSI for the

workplace where I am. This works nicely and does what I need it to do (send text and files).

I have installed jabberd on gentoo a few times only. However I have just installed again to test this

document and all worked fine.

Firewall.[/i]

If you have a firewall running on your jabber server, you will need to poke a hole in it for it to be used. The ports you will 

need to open are...

--dport 5222,5223,5269

Good luck all. I hope this helps someone out.

>Craig  :Smile: 

----------

## linuxpyro

OK, I followed everything, but when I start Jabber I get the following error:

ERROR: sm died.  Shutting down server.

Anyone seen this before?

----------

## Flummi

... already had it working, but somehow killed it. With your short step-by-step instructions it works now again. :Very Happy: 

Flummi

----------

## volkris

Of course, using mysql adds quite a bit of complexity to these instructions... the bdb driver is just fine and far simpler.

----------

## xmwxd

 *linuxpyro wrote:*   

> OK, I followed everything, but when I start Jabber I get the following error:
> 
> ERROR: sm died.  Shutting down server.
> 
> Anyone seen this before?

 

I have the same problem,Because my jabberd2 was installed by emerge .

when I installed it step by step ,It works.

I don't Know which step cause this problem?

anybody can fix it?

also a problem ,How to test the server?

----------

## dm3

There is a mismatch between the config files and the install scripts. The files are looking for some things under /var/lib/jabberd while the install scripts create /var/jabberd.   Edit these files:

```

c2s.xml:  <pidfile>/var/lib/jabberd/pid/c2s.pid</pidfile>

resolver.xml:  <pidfile>/var/lib/jabberd/pid/resolver.pid</pidfile>

router.xml:  <pidfile>/var/lib/jabberd/pid/router.pid</pidfile>

s2s.xml:  <pidfile>/var/lib/jabberd/pid/s2s.pid</pidfile>

sm.xml:  <pidfile>/var/lib/jabberd/pid/sm.pid</pidfile>

```

and remove the "lib" component from the pathname.

In sm.xml and c2s.xml you'll also need to fix the path for the database in the same way. It should look like this: <path>/var/jabberd/db</path> when you're done.

----------

## ivanova

Is it possible to run jabberd on a local network without registered host name?

If someone can give some tips I'd appreciate it.

----------

## xces

 *ivanova wrote:*   

> Is it possible to run jabberd on a local network without registered host name?

 

Of course it is. You just have to set the intended hostname in sm.xml and c2s.xml. The hostname has to be valid and should be resolvable in your local network (e. g. jabber.local with corresponding entry in /etc/hosts or your local nameserver).

----------

## ivanova

thanks - got it working  :Wink: 

----------

## sparky007

After following this howto and attempting to start the server, I was getting  

```
ERROR: sm died.  Shutting down server.
```

or

```
ERROR: c2s died.  Shutting down server.
```

or

```
ERROR: s2s died.  Shutting down server.
```

The problem was due to setting the hostaname in the wrong id element in c2s.xml.

If you are getting this problem, make sure you set your hostname in the <id> element that is within the <local> element, not the top level <id> element.

The solution can be found here:

http://juffo.org/wiki/JabberdRouterAlreadyBound

(This is mentioned in the howto but you may have overlooked it like I did).

----------

## Phobos666

and how can i get icq/msn/yahoo to jabber with jabberd2?

----------

