【发布时间】:2015-09-04 16:39:16
【问题描述】:
命令
$file = '/var/www/test.docx';
move_uploaded_file($uploaded_file, $file);
echo 'is file: '.is_file($file)."\n";
exec('/usr/bin/doc2pdf -o '.$file.'.new '.$file.' 2>&1', $out);
print_r($out);
输出
is file: 1
Array
(
[0] => Error: Unable to connect or start own listener. Aborting.
)
这是上传脚本的一部分,在 Apache 下以 www-data 运行..
命令行单独在腻子中工作正常,如root
脚本在www-data 下运行,但现在不行了? :-/
更新我
apt-get install sudo
sudo visudo # added "www-data ALL = NOPASSWD: /usr/bin/doc2pdf"
代码:
exec('sudo /usr/bin/doc2pdf -o '.$file.'.new '.$file.' 2>&1', $out);
print_r($out);
错误:
sudo: unable to resolve host dyntest-amd-3700-2gb
更新二
echo "127.0.1.1 $(hostname)" >> /etc/hosts
reboot
【问题讨论】:
-
将
-v选项添加到您的doc2pdf命令并检查$out的输出。此外,sudo通常需要一个 tty。检查/etc/sudoers文件中的Defaults requiretty选项。请参阅此 StackExchange 帖子:unix.stackexchange.com/a/122624。