[英]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.