5

When I try to run sudo yum install php-imagick

I'm getting this response:

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                                                                                                                                                                                                                                                      | 3.7 kB  00:00:00     
299 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package php-pecl-imagick.x86_64 0:3.4.4-10.el7.remi.7.4 will be installed
--> Processing Dependency: libMagickCore-6.Q16.so.6()(64bit) for package: php-pecl-imagick-3.4.4-10.el7.remi.7.4.x86_64
--> Processing Dependency: libMagickWand-6.Q16.so.6()(64bit) for package: php-pecl-imagick-3.4.4-10.el7.remi.7.4.x86_64
--> Finished Dependency Resolution
Error: Package: php-pecl-imagick-3.4.4-10.el7.remi.7.4.x86_64 (remi-php74)
           Requires: libMagickCore-6.Q16.so.6()(64bit)
Error: Package: php-pecl-imagick-3.4.4-10.el7.remi.7.4.x86_64 (remi-php74)
           Requires: libMagickWand-6.Q16.so.6()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

Server is on Amazon Linux 2 and PHP version is 7.4.7

Nikko R.
  • 178
  • 1
  • 11

3 Answers3

18

This is the cleanest way I found of doing it (under PHP 7.4 on Amazon Linux AMI 2):

sudo yum -y install php-pear php-devel gcc ImageMagick ImageMagick-devel
sudo bash -c "yes '' | pecl install -f imagick"
sudo bash -c "echo 'extension=imagick.so' > /etc/php.d/imagick.ini"

If you're using php-fpm, don't forget to restart it:

sudo systemctl restart php-fpm.service
Jonathan
  • 13,947
  • 17
  • 94
  • 123
  • 2
    I tried this method with Amazon Linux AMI 2 with PHP 7.4 and it worked for my WordPress. Thank you! – Hiro Mar 02 '21 at 03:57
7

I finally got it working. Here are the commands that I used. First setup Amazon linux to use php7.4

sudo yum install -y amazon-linux-extras
sudo amazon-linux-extras disable php7.2
sudo amazon-linux-extras disable lamp-mariadb10.2-php7.2
sudo amazon-linux-extras enable php7.4

Now install PHP and some additional libs

sudo yum clean metadata
# The following line may not be needed, but it was part of my script
sudo yum -y install php-cli php-pdo php-fpm php-json php-mysqlnd php-xml php-mbstring php-soap php-gd
sudo yum -y install php-pear php-devel gcc 
sudo yum -y install ImageMagick ImageMagick-devel ImageMagick-perl
sudo pecl install imagick
sudo chmod 755 /usr/lib64/php/modules/imagick.so

Add extension=imagick.so to the Dynamic Extensions section of the file.

sudo vi /etc/php.ini
AwkDenver
  • 166
  • 3
  • 9
  • 1
    You can also automate adding the extension with `echo "extension=imagick.so" | sudo tee /etc/php.d/20-imagick.ini` since the files in php.d are autoloaded. Also do not forget to restart php-fpm (if you're using fastcgi) and httpd/nginx! – Andrey Tsarev Jan 27 '21 at 10:13
1

My repository is firstly designed for RHEL and CentOS.

In version 7.8, ImageMagick was rebased to 6.9.10, and php-pecl-imagick requires, at least, this new version.

So looks like Amazon is still late behind.

You can enable "remi" repository , which provides latest version (6.9.11-28 for now)

# yum --enablerepo=remi,remi-php74 install php-pecl-imagick

For memory, this was tracked as #144

Remi Collet
  • 6,198
  • 1
  • 20
  • 25
  • Tried that but got this error instead: Error: Package: ImageMagick-libs-6.9.11.33-1.el7.remi.x86_64 (remi) Requires: libraw_r.so.19()(64bit) You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest – Nikko R. Oct 08 '20 at 22:16