简体   繁体   中英

PHP ImageMagick convert doesn't work under OSX

I have an apache web server under OSX and an installed and configured ImageMagick. If I try to execute some ImageMagick command from the terminal, it works fine, but if I try to do that with exec or shell_exec from PHP, it doesn't work.

That is what I do: I set the environment variable:

apache_setenv("PATH", "/etc/ImageMagick-6.8.1/bin:".apache_getenv("PATH"));

and try to execute some command:

exec('convert -version', $imgkOut);

the $imgkOut array is always empty.

I tried to set both paths: 'convert ...' and '/etc/ImageMagick-6.8.1/bin/convert ...' - nothing helps.

In the apache log file I found these errors:

sh: convert: command not found

for the first case, and this:

sh: /etc/ImageMagick-6.8.1/bin/convert: Permission denied

for the second.

What do I do wrong?

  1. did you see http://php.net/manual/en/book.imagick.php ?
  2. try install imagemagick from macports - http://www.macports.org/ports.php?by=name&substr=imagemagick
  3. check exec for convert (maybe file hasnt +x flag? so just chmod +x convert)

The errors you are getting imply that:

  1. The apache_setenv command is not working.
  2. The web user does not have permission to run the command.

If you do

    cd /etc/ImageMagick-6.8.1/bin
    chmod +x convert

and try again with the second version, where you supply the complete path, it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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