Skip to content

Instantly share code, notes, and snippets.

@nivv
Last active November 28, 2021 11:38
Show Gist options
  • Star 34 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save nivv/5d9a12af5472b91606e6 to your computer and use it in GitHub Desktop.
Save nivv/5d9a12af5472b91606e6 to your computer and use it in GitHub Desktop.
Guide - Enable imagick on PHP7

Guide

Note The extension Imagick is now included in Ondrej's PPA. All you need to do now is $ sudo apt-get install php-imagick, and you're done. I'll keep the guide here because a lot of it is still true for other extensions

======

I've installed PHP7 via Ondrej's PPA. He maintains these PPA's on his free time, consider donating

Install dependencies

$ sudo apt-get install php7.0-dev
$ sudo apt-get install pkg-config
$ sudo apt-get install libmagickwand-dev
$ sudo apt-get install imagemagick
$ sudp apt-get install build-essential
# Or
$ sudo apt-get install -y php7.0-dev pkg-config libmagickwand-dev imagemagick build-essential

Download extension

Mikko Koppanen have a PHP 7 compatible build of imagick. Be sure to download the phpseven branch (We're doing that below). I suppose you could clone the repo if you want the latest changes available more easily

I usually create a download directory for temporary downloads

mkdir downloads
$ cd downloads
$ wget https://github.com/mkoppanen/imagick/archive/phpseven.zip

Unzip it:

$ unzip phpseven.zip

Cd into it

$ cd imagick-phpseven

Make extension

Phpize it

$ phpize

Configure it and run make

$ ./configure
$ make
$ sudo make install

Tell PHP about the extension (Modified steps from Fideloper's guide for sphinx)

$ echo "extension=imagick.so" | sudo tee /etc/php/mods-available/imagick.ini

# Symlink it to fpm
$ sudo ln -s /etc/php/mods-available/imagick.ini /etc/php/7.0/fpm/conf.d/20-imagick.ini

# Symlink it to cli
$ sudo ln -s /etc/php/mods-available/imagick.ini /etc/php/7.0/cli/conf.d/20-imagick.ini

# Reload php-fpm
sudo service php7.0-fpm reload

Done!

@collmomo
Copy link

nice guide. Don't forget to install sudo apt-get install php-dev for phpize for php7. Also deleting php5-dev for any confusion sudo apt-get --purge remove php5-dev and if you don't use php fpm reload this way sudo service apache2 restart.

Thanks for the guide.

@jangsoopark
Copy link

In Install dependencies
sudp apt-get install build-essential [x] => sudo apt-get install build-essential

@filatoff
Copy link

filatoff commented Apr 7, 2016

Its great guide. Thanks!

@metisast
Copy link

nice guide, but remove fisrt tell $ echo "extension=imagick.so" | sudo tee /etc/php/mods-available/imagick.ini on
$ echo "extension=imagick.so" | sudo tee /etc/php/**7.0/**mods-available/imagick.ini

@matrunchyk
Copy link

matrunchyk commented May 17, 2016

nice guide, but remove fisrt tell

And not the first only. The second and third line has the error as well. Please fix it

@karborator
Copy link

CentOS way ?

@jaymecd
Copy link

jaymecd commented Jun 19, 2016

After install on alpine:3.4 (php:7.0.7) got SegFault:

# php --ri imagick; echo "Exit Code: $?"

imagick

imagick module => enabled
imagick module version => @PACKAGE_VERSION@
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version => ImageMagick 6.9.4-1 Q16 x86_64 2016-05-16 http://www.imagemagick.org
Imagick using ImageMagick library version => ImageMagick 6.9.4-1 Q16 x86_64 2016-05-16 http://www.imagemagick.org
ImageMagick copyright => Copyright (C) 1999-2016 ImageMagick Studio LLC
ImageMagick release date => 2016-05-16
ImageMagick number of supported formats:  => 217
ImageMagick supported formats => 3FR, AAI, AI, ART, ARW, AVI, AVS, BGR, BGRA, BGRO, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, FAX, FITS, FRACTAL, FTS, G3, GIF, GIF87, GRADIENT, GRAY, GROUP4, GV, H, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, JNG, JNX, JPE, JPEG, JPG, JPS, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WEBP, WMV, WPG, X3F, XBM, XC, XCF, XPM, XPS, XV, YCbCr, YCbCrA, YUV

Directive => Local Value => Master Value
imagick.locale_fix => 0 => 0
imagick.skip_version_check => 0 => 0
imagick.progress_monitor => 0 => 0
Segmentation fault
Exit Code: 139

version from PECL has same issue

@tixastronauta
Copy link

Any hint on installing on CentOS/Amazon Linux?

@roza2404
Copy link

After executing these commands following error is occurred and i am using ubuntu16.04 please help me thank you! please help me

/home/desktop/download/imagick-phpseven/imagick_helpers.c: In function ‘php_imagick_progress_monitor_callable’:
/home/desktop/download/imagick-phpseven/imagick_helpers.c:96:5: error: ‘zend_fcall_info {aka struct _zend_fcall_info}’ has no member named ‘function_table’
fci.function_table = EG(function_table);
^
/home/desktop/download/imagick-phpseven/imagick_helpers.c:111:5: error: ‘zend_fcall_info {aka struct _zend_fcall_info}’ has no member named ‘symbol_table’
fci.symbol_table = NULL;
^
Makefile:204: recipe for target 'imagick_helpers.lo' failed
make: *** [imagick_helpers.lo] Error 1

@oimtrust
Copy link

Please, how to install on Mac OS?

@Delivator
Copy link

Typo in https://gist.github.com/nivv/5d9a12af5472b91606e6#install-dependencies
Second last command you wrote sudp :)

@pherrymason
Copy link

@pierrototo
Copy link

Hi !

You should replace your :
wget https://github.com/mkoppanen/imagick/archive/phpseven.zip
by :
pecl install imagick-beta

It normally solved the issue.

Best regards,

@eplt
Copy link

eplt commented Jun 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment