[英]Commands working fine in putty but not using exec() in PHP
So I have installed shhavel's facerec ( https://github.com/shhavel/facerec ) on my VPS (Ubuntu 14.04.5) and it works perfectly fine when I use it from within putty: 所以我已经在我的VPS(Ubuntu 14.04.5)上安装了shhavel的facerec( https://github.com/shhavel/facerec ),当我从腻子中使用它时,它的工作效果非常好:
facerec list
jenniferlawrence
emmawatson
However, from within PHP when using the exec() function, the only command that works is facerec -help, all other commands produce an error similar to the following: 但是,在PHP中使用exec()函数时,唯一有效的命令是facerec -help,所有其他命令都会产生类似于以下内容的错误:
facerec list 2>&1 facerec清单2>&1
Traceback (most recent call last):
File "/usr/local/bin/facerec", line 359, in
sys.exit(__main__())
File "/usr/local/bin/facerec", line 356, in __main__
return args.func(args)
File "/usr/local/bin/facerec", line 159, in list
for subject in os.listdir(subjects_directory):
OSError: [Errno 2] No such file or directory: './subjects'
The PHP script: PHP脚本:
exec('facerec list 2>&1', $output);
foreach($output as $string) {
echo $string."<br>";
}
How do I approach fixing this problem? 我该如何解决此问题?
Found the problem: 发现问题:
The "subjects"-folder was located in /root/ which the PHP script did not have the permission to access “主题”文件夹位于/ root /中,PHP脚本无权访问该目录
Possible solutions: 可能的解决方案:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.