views:

39

answers:

2

I am working on a php social network that requires us to create XMPP accounts for all new members. I have a working Ejabberd server running with mod_admin_extra all working fine.

I am trying to call ejabberdctl from a php file like so:

exec('sudo /home/user/ejabberd-2.1.2/bin/ejabberdctl register test server pass 2>&1');

but i get the following error :

Failed RPC connection to the node ejabberd@localhost: nodedown

Although the same command works from the command line.

I have also added the following to /etc/sudoers :

www-data ALL= NOPASSWD: /home/webuser/ejabberd-2.1.2/bin/ejabberdctl

So what gives?

A: 

This sometimes happens if you start ejabberd with an user and then use another user to restart, so maybe it has something to do with the user who's running the command through php?

sofia
A: 

Avoid using sudo, copy over the ejabberd cookie to your www user and call ejabberdctl directly.

Also, you may want to look into mod_xmlrpc which will allow you to execute any ejabberdctl commands over a XMLRPC interface.

Andrew Williams