简体   繁体   English

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

[英]How to set permissions in php for shell_exec command

I need to execute ImageMagick's convert via shell_exec in a php file running apache as localhost on a mac running snow leopard. 我需要在运行雪豹的mac上通过shell_exec作为localhost运行php文件中,通过shell_exec执行ImageMagick的convert I have tried all sorts of tips, tricks, edits and permissions garnered from a multitude of questions and solutions from here. 我尝试了来自此处的众多问题和解决方案的各种技巧,窍门,编辑和权限。 But nothing seems to do the trick. 但是似乎没有办法解决问题。 The php file below highlights the problem: 下面的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

?>

I assume this is a permissions problem: but where, on which file? 我认为这是一个权限问题:但是在哪个文件上呢?

EDIT: The full error message is: 编辑:完整的错误消息是:

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

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

You are executing convert successfuly, but then the convert itself is returning the error convert: UnableToCreateTemporaryFile and then convert: NoImagesDefined . 您正在成功执行convert ,但是convert本身返回错误convert: UnableToCreateTemporaryFile and then convert: NoImagesDefined

I think this is the answer to the underlying question can be found at https://superuser.com/questions/819277/cant-convert-pdf-into-image-because-of-no-images-defined-error 我认为这是基本问题的答案,可以在https://superuser.com/questions/819277/cant-convert-pdf-into-image-cause-of-no-images-defined-error中找到

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM