[英]How to set permissions in php for shell_exec command
我需要在运行雪豹的mac上通过shell_exec
作为localhost运行php文件中,通过shell_exec
执行ImageMagick的convert
。 我尝试了来自此处的众多问题和解决方案的各种技巧,窍门,编辑和权限。 但是似乎没有办法解决问题。 下面的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.
您正在成功执行convert
,但是convert
本身返回错误convert: UnableToCreateTemporaryFile and then convert: NoImagesDefined
。
我认为这是基本问题的答案,可以在https://superuser.com/questions/819277/cant-convert-pdf-into-image-cause-of-no-images-defined-error中找到
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.