使用PHP exec函数 执行 sduo的时,提示权限不足,具体报错如下:


array(9) {
  [0]=>
  string(0) ""
  [1]=>
  string(66) "We trust you have received the usual lecture from the local System"
  [2]=>
  string(59) "Administrator. It usually boils down to these three things:"
  [3]=>
  string(0) ""
  [4]=>
  string(38) "    #1) Respect the privacy of others."
  [5]=>
  string(30) "    #2) Think before you type."
  [6]=>
  string(52) "    #3) With great power comes great responsibility."
  [7]=>
  string(0) ""
  [8]=>
  string(53) "sudo: no tty present and no askpass program specified"
}

解决方法如下:
编辑 /etc/sudoers 文件。
在此处:

## Next comes the main part: which users can run what software on 
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##     user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere 
root    ALL=(ALL)     ALL

追加下方代码:

www ALL = NOPASSWD: ALL
## Next comes the main part: which users can run what software on 
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##     user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere 
root    ALL=(ALL)     ALL
www ALL = NOPASSWD: ALL

这样就可以解决了。