Skip to content

Instantly share code, notes, and snippets.

@nivv
Last active November 28, 2021 11:38
Show Gist options
  • 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!

@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