Search code examples
phppearimagickpecl

Imagick installation error permission denied


I followed all the steps to install imagick on php 7 / centos 7 and at this step I get an error:

pecl install Imagick

. . . . Lots of stuff going on.... .

ERROR: failed to write /usr/lib64/php/modules/imagick.so (copy(/usr/lib64/php/modules/imagick.so): failed to open stream: Permission denied)


Why is this happening? I installed all php modules as root user.


Solution

  • The problem was with php7! Instead of running

    pecl install imagick
    

    I needed to do

    sudo yum install php70w-pecl-imagick
    

    And

    php -i | grep Imagick
    

    produces:

    imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
    Imagick compiled with ImageMagick version => ImageMagick 6.7.8-9 2016-06-16 Q16 http://www.imagemagick.org
    Imagick using ImageMagick library version => ImageMagick 6.7.8-9 2016-06-16 Q16 http://www.imagemagick.org
    


    Obviously, I added extension=imagick.so to my php.ini file :)
    Moral of the story is to find the right packages to install for php 7...almost every online tutorial (at this time at least) is referring to packages which are meant for older versions of PHP.