如何在php中为shell_exec命令设置权限

时间:2014-11-30 13:38:32

标签: php macos permissions

我需要在运行apache的php文件中通过convert执行Image shell_exec作为运行雪豹的mac上的localhost。我已尝试过从这里获得的各种问题和解决方案中提供的各种提示,技巧,编辑和权限。但似乎没有什么可以做到的。下面的php文件突出显示了问题:

<?php
  echo shell_exec('whoami');  //daemon. I chown-ed convert by daemon
  apache_setenv('PATH', '/usr/local/bin:/usr/bin:/bin'); // this works: checked with getenv("PATH");
  echo shell_exec('cp /Users/fullpath/file.pdf  /Users/fullpath/file.pdf 2>&1'); // this works, so shell_exec works
echo shell_exec('/usr/local/bin/convert /Users/fullpath/file.pdf  /Users/fullpath/file.png  2>&1'); // this fails, convert: UnableToCreateTemporaryFile and then convert: NoImagesDefined

?>

我认为这是一个权限问题:但是在哪个文件上?

编辑:完整的错误消息是:

convert: UnableToCreateTemporaryFile `/Users/fullpath/file.pdf': Permission denied @ error/pdf.c/ReadPDFImage/390.

convert: NoImagesDefined `/Users/fullpath/file.png' @ error/convert.c/ConvertImageCommand/3021.

1 个答案:

答案 0 :(得分:0)

您正在成功执行convert,但convert本身正在返回错误convert: UnableToCreateTemporaryFile and then convert: NoImagesDefined

我认为这是可以在https://superuser.com/questions/819277/cant-convert-pdf-into-image-because-of-no-images-defined-error

找到基本问题的答案