问题
Command:convert | head -n 4
Shows this
Version: ImageMagick 6.7.8-9 2014-05-12 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC Features: OpenMP
Then when i run this:
<?php
$imagick = new Imagick();
$imagick->readImage('test.pdf');
$imagick->writeImages('image.jpg', false);
echo 'Aw';
?>
Shows this error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/5.6/modules/imagick.so' - /usr/lib64/php/5.6/modules/imagick.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Fatal error: Class 'Imagick' not found in /var/www/html/test/imagick/index.php on line 2
I added extension=imagick.so to my
etc/php.ini
etc/php-5.6.ini
etc/php-5.5.ini
I always execute this first when testing sudo service httpd restart
My reference: https://gist.github.com/ARolek/9199329
回答1:
Try this
yes | yum install kernel-devel gcc gcc-c++
yes | yum install php-devel
yum install php-pear # This line installs pecl as well as pear
yum install ImageMagick-devel
pecl install imagick
Add extension-imagick.so to /etc/php.ini
service httpd restart
回答2:
Looks like you have ImageMagick installed, but not the PECL Imagick module.
The easiest way would be to use the pecl utility.
pecl install imagick
If the pecl utility is not available, you can do this manually.
curl -o imagick-latest.tgz https://pecl.php.net/get/imagick
tar zxvf imagick-latest.tgz
cd imagick-VERSION_HERE
phpize
./configure
make
make test # optional but a good idea
sudo make install
Pay attention to the output of make install. If the php.ini doesn't pick it up automaticly, you can update the extension setting to the absolute path.
extension=/usr/local/lib/php/extensions/no-debug-non-zts-VERSION/imagick.so
来源:https://stackoverflow.com/questions/31625316/amazon-ec2-linux-imagemagick-issues