Friday, October 15, 2010

Getting started with Ejabberd on Ubuntu

This is a post on getting started on Ejabber on Linux. I am using Ubuntu 10.04 but it should be the same on most linux flavors. This is part of a html5-xmpp project I am doing with a friend. More on that later.

Lets get started!

Install Ejabberd
>sudo apt-get install ejabberd

Give user admin rights
To give user admin rights you need to edit the config file.
>sudo nano /etc/ejabberd/ejabberd.cfg
In the file you need to add a user who will be admin. To confuse matters, I will call this user "admin" and put him on the host "localhost" which is default.
%% Admin user
{acl, admin, {user, "admin", "localhost"}}.

Ctrl-X to Exit and Save

Register User
Ejabber comes with a admin command called ejabberctl, with that you can do the most wonderful things. Lets register the user "admin" on "localhost" with the password "secret"
>sudo ejabberdctl register admin localhost secret

See all registered user
To see all the users on a host run "ejabberdctl registered_users"
>sudo ejabberdctl registered_users localhost
ejabberdctl should now return a simple
admin

Register bunch of users
Lets register two users, we will need them in the next post
>sudo ejabberdctl register jonas localhost jonas
>sudo ejabberdctl register jonas2 localhost jonas2
>sudo ejabberdctl register jonas3 localhost jonas3


Unregister User
This is how you unregister users if you need to do that.
>sudo ejabberdctl unregister jonas3 localhost

Restart Server
Lets restart the server
>sudo ejabberdctl restart

Webadmin
There is a webadmin where you can administer and monitor your ejabber server
Go to http://localhost:5280/admin/
Log in with admin/secret to see all the wonderful stats

Get ready for XMPP


Now that we have the server up and running with a bunch of users, we need to check if it's equipped with http-bind so that we can use BOSH for XMPP communication.

Edit config file
Make sure your config file has http-bind enabled
>sudo nano /etc/ejabberd/ejabberd.cfg
It should look like this:
{5280, ejabberd_http, [
http_bind,
http_poll,
web_admin
]}


And add the http_bind module
{modules,
[
...
{mod_http_bind, []},
...
]}

Lets restart the server
sudo ejabberdctl restart

Verify it on the webpage
Go to http://localhost:5280/http-bind
You should now see a text which reads something like
ejabberd mod_http_bind v1.2
An implementation of XMPP over BOSH (XEP-0206)
This web page is only informative. To use HTTP-Bind you need a Jabber/XMPP client that supports it.


Great, now everything seems to be working. Now check out the next post to get Strophe.js and Nginx up and running!

No comments: