Question

I am executing a SUDO command in PHP script,

$username = 'tester';
$password = 'testerspassword';
$node = 'localhost';
exec('sudo /usr/sbin/ejabberdctl register '.$username.' '.$node.' '.$password.' 2>&1',$output,$status);

When i am trying with putty and executing same as

sudo ejabberdctl register testuser1 localhost pass123

Its working , but through PHP script its not working. How to execute it through PHP script,If required to include .ppk file and username for verification then how to use it ?

Thanks in advanced!

Was it helpful?

Solution

PHP is executed under the user account of Apache.

You should add this user(usually called www-data, apache or similar) to /etc/sudoer...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top