ImageMagick Logo

We’re a big fan of PHP-FPM and chrooting, all of our deployments use this along with per-site UIDs to ensure complete isolation and resource control.

This week we ran into an issue where a client needed the ImageMagick PECL module (and therefore the ImageMagick package) installed. After configuring the extension and reloading PHP-FPM we saw the module come up under phpinfo(), however there was an issue:

ImageMagick number of supported formats: 0
ImageMagick supported formats: none

ImageMagick was loaded, but couldn’t actually decode anything, if we tried we’d see errors like this:

NoDecodeDelegateForThisImageFormat 'JPEG' @ error/constitute.c/ReadImage/501

The solution was to create a usr/local/lib directory inside the site’s chroot directory and copy the entire ImageMagick libraries subdirectory into it:

cd /data/sites/;
mkdir -p usr/local/lib/;
cp -Rpv /usr/local/lib/ImageMagick-6.9.1 usr/local/lib/;

Obviously adjusting the directory for the exact version you are using and also keeping in mind that these files need to be manually kept up to date when ImageMagick itself is updated on the system level.

One Response to “ImageMagick Under PHP-FPM and Chroot”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.