Setting up chat server (xmpp) using prosody

Prosody is an excellent and easy way to quickly setup an XMPP/jabber server running up in minutes.

without spending more words follow the steps:

1. Install prosody server

apt-get install prosody

2. Configure

Edit the following lines

admins = { “admin@yourdomain.com” } // this account will be created later

modules_enabled = {} // add another module entry called “admin_web”

authentication = “internal_hashed” // hashed password storage

VirtualHost “yourdomain.com” // turn on this virtual host
enabled = true

3. Web interface for admin user

Get the admin_web module folder from https://code.google.com/p/prosody-modules/source/browse/ as zip

Extract the zip and copy the admin_web folder to prosody module folder (typically /usr/lib/prosody/modules). After this you need to run the shell script under admin_web

/usr/lib/prosody/modules/admin_web#>./get_deps.sh

above will download dependencies and complete the installation.

Next create first user (admin) from command line

prosodyctl adduser admin@yourdomain.com

Open the admin interface from http://yourdomain.com:5280/admin/ to add more users or configure the server.

4. Testing your IM server

Install any of XMPP/Jabber IM client such as jitsy, empathy etc (there are lot of them) for Android Linux and Windows, enter the username test@localhost and whatever password was given for user. Unselect any encrypted connection option in the client.

It should be connected and ready to chat after you add more users and contacts.

Occasional problems with php exec() function

PHP exec or its variant like system() are excellent way to run the critical jobs via a third party executable program, mostly use of this program is straightforward but rarely due to system setting we may end up error codes or empty output.


exec("java -version", $output, $code);

Error code 0 means everything is ok and exec was successful.

First look at the following link for exec code returned from this method

PHP exec() Error Codes

Most likely you may hit by error code 127 means program path was not found then you have to try giving full path of executable because apache may not have information about system environment variables, example;


exec("/usr/local/java/jdk_1.7 -version", $output, $code);

Another common error code is 126 means apache do not have permission to execute the code to solve this create group and add all users to this group including www-data which are required to execute that program, then change the directly ownership and mode recursively.

Another bizarre problem is when you have 0 returned but $output is empty to solve this add 2&>1 to the end of command for example;


exec("java -version 2>&1", $output, $code);

alloc_gdi_handle out of GDI object handles : wine error

If you are developing and testing win32 applications under Linux using a cross compiler and wine, there is chance you may end up error like below;

alloc_gdi_handle out of GDI object handles

A common cause for this error is large stack buildup of win32 gdi objects which were not released consequently.

try to append the following line in your code.

I give two example

HDC hdc = GetDC(handle);
// some work with hdc
ReleaseDC(handle, hdc); // <— add this line

Delete created HFONT objects using when they are not required

DeleteObject();