문제

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!

도움이 되었습니까?

해결책

PHP is executed under the user account of Apache.

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top