well, just after upgrading my Ubuntu and therefore moving to php7, I seem not to be able to install imagick extension for php using the same old command

sudo apt-get install php5-imagick

I get this error (tried php7-imagick too)

 Package php5-imagick is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'php5-imagick' has no installation candidate

what should I do?

  • 5
    I think it is just sudo apt install php-imagick.
    – Terrance
    Commented May 8, 2016 at 17:01
  • 1
    Can confirm, apt-cache search shows that php-imagick is the package for php7.
    – DopeGhoti
    Commented May 8, 2016 at 17:06

5 Answers 5


Just do:

sudo apt-get install php-imagick

This should install imagick for PHP 7.0.

  • 1
    On my system this tries to install php 5.5 along with it. Commented Aug 11, 2016 at 14:54
  • I got: WARNING: The following packages cannot be authenticated! php-imagick Install these packages without verification? [y/N] y Err ppa.launchpad.net/ondrej/php-7.0/ubuntu trusty/main php-imagick amd64 3.4.0~rc6-1+deb.sury.org~trusty+2 404 Not Found E: Failed to fetch ppa.launchpad.net/ondrej/php-7.0/ubuntu/pool/main/p/php-imagick/… 404 Not Found E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
    – mwm
    Commented Sep 25, 2016 at 14:41
  • 4
    Worked, but I had to follow @alexg advice to restart service php7.0-fpm
    – xl-t
    Commented Feb 15, 2017 at 13:18
  • 1
    You may need to run apt-get update and apt-get upgrade (or apt-get dist-upgrade prior to running apt-get install php-imagick Commented Feb 6, 2018 at 20:15
  • Don't forget to restart apache if PHP7 is running as an apache module.
    – Hokascha
    Commented Jan 23, 2019 at 15:55

Turns out I had to restart the fpm:

sudo service php7.0-fpm reload

Things I tried:

apt install php-imagick didn't work for me. The module was getting loaded for the PHP CLI (I checked with php -m | grep -i imagick but through my nginx webserver it didn't show up in the list of modules reported by phpinfo() at all.

I even inserted extension=imagick.so to /etc/php/7.0/fpm/php.ini manually, just to make sure.

I then tried purging the php-imagick package and installing from cpan:

sudo apt install libmagickwand-dev imagemagick php-dev
sudo pecl install imagick

And still, no cigar. It would work through the cli but not via nginx.

  • Necromancer here, sorry, but gush after 30 minutes your line mentioning the restart of php service made me really feel like I should bang my head into the brick wall... :) Yes you guessed it, I forgot that bit and I was going mental why it's not working :D Commented Feb 8, 2018 at 22:05
  • @alexg since we aren't compiling imagemagick is there any reason using -dev package of libmagickwand?
    – inckka
    Commented May 22, 2018 at 1:02
  • 1
    @inckka no, you should be OK with the binary package. Thanks!
    – alexg
    Commented Jun 4, 2018 at 6:10

For php 5.6: sudo apt-get install php5.6-imagick

For php 7.0:sudo apt-get install php7.0-imagick

For php 7.1: sudo apt-get install php7.1-imagick

For php 7.2: sudo apt-get install php7.2-imagick

For php 7.3: sudo apt-get install php7.3-imagick

For php 7.4: sudo apt-get install php7.4-imagick

For php 8.0: sudo apt-get install php8.0-imagick

For php 8.1: sudo apt-get install php8.1-imagick

After restart apache:sudo service apache2 reload

  • 3
    Can't believe this was so far down a rabbit hole, this is perfect - thanks.
    – Eric
    Commented Apr 14, 2021 at 14:58
  • 2
    Only thing that worked! Commented Aug 4, 2021 at 9:31
  • 1
    Thank you so much!
    – RPF
    Commented Aug 23, 2021 at 12:00
  • 1
    Works great! This must be the answer on top! Commented Sep 12, 2021 at 14:33
  • 1
    That is the only code that works!. thanks man. Commented Dec 19, 2021 at 9:19

Installed these packages:

sudo apt install libmagickwand-dev imagemagick php-dev
sudo pecl install imagick

Now replace:

sudo service php7.0-fpm reload


sudo service apache2 restart

Works Great

  • its worked for me
    – matinict
    Commented Apr 4, 2019 at 7:13
  • What are "libmagickwand-dev imagemagick php-dev" used for? I see those libraries have a hard size Commented Jun 24, 2021 at 22:45

Now it is 2018, just wanted to highlight, in many cases, you would also want to install php-gd along with php-imagick (if you are installing this for wordpress for example).

sudo apt install php-imagick php-gd 
sudo systemctl restart apache2

The use of php-imagick implies php7.2-imagick if 7.2 is what your php version is.

  • 1
    php-gd is optional if you have imagick installed
    – Aurovrata
    Commented Dec 5, 2019 at 10:17
  • Seems this works for many people but for me, running sudo apt install libmagickwand-dev imagemagick php-dev says imagemagick is already the newest version but that there are unmet dependencies. When I try to install the dependency, it says there is another and so forth for about a half-dozen different ones, none of which will install. The last one is for libpcre3 and when I try to install it, I am told that the latest one is already installed! What is going on?
    – DonP
    Commented Dec 14, 2019 at 23:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .