2013-12-09 10:30
浏览 102


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!

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dora0817 2013-12-09 10:40

    PHP is executed under the user account of Apache.

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

    解决 无用
    打赏 举报

相关推荐 更多相似问题