允许apache运行一个sphinx命令

我需要Apache能够运行狮身人面像索引工具,因为我正在build立一个基于Web的界面来重新索引和检查各种狮身人面像configuration。

目前我已经添加以下visudo

 Defaults:%apache !requiretty Defaults:apache !requiretty apache ALL=(sphinx) NOPASSWD: /usr/bin/indexer, /usr/bin/indexer 

我正在运行的命令是:

 exec sudo -u sphinx indextool --checkconfig --config /path/to/sphinx.conf 

这是用PHP的proc_open运行的

 array( 'stdin' => array('pipe', 'r'), 'stdout' => array('pipe', 'w'), 'stderr' => array('pipe', 'w'), ) 

错误:

 sudo: no tty present and no askpass program specified 

原来,我需要使用命令的完整path

  exec sudo -u sphinx /usr/bin/indextool --checkconfig --config /path/to/sphinx.conf 

现在一切正常