How to install ImageMagick, ImageMagick-devel and PECL imagick on RHEL 8

Tony Clemmey picture Tony Clemmey · Feb 28, 2020 · Viewed 7.6k times · Source

It appears ImageMagick and ImageMagick-devel are removed from RHEL 8.

I have added 3rd party repositories such as EPEL, REMI, & RPMFusion.

I am able to install the GraphicsMagick replacement for Imagemagick but it appears Gmagick is not compatible with ImageMagick at PHP library code level.

So the below method does not help... for the plugin I am using which depends on PHP Imagemagick, while using Gmagick to convert something in the CLI it will work.

$ dnf install GraphicsMagick GraphicsMagick-devel GraphicsMagick-perl ghostscript
$ cd /usr/local/src
$ wget https://pecl.php.net/get/gmagick
$ tar xfvz gmagick $ cd gmagick-*
$ phpize 
$ ./configure
$ make
$ make installl
$ php --ini | grep 'Loaded Configuration File'
$ nano /etc/php.ini
// add extension to end of php.ini
extension=gmagick.so

When trying to install ImageMagick

$ sudo yum install ImageMagick-devel

No match for argument: ImageMagick-deval
Error: Unable to find a match: ImageMagick-deval

$ pecl install imagick

checking whether to enable the imagick extension... yes, shared
checking for pkg-config... /bin/pkg-config
checking ImageMagick MagickWand API configuration program... checking
Testing /usr/local/bin/MagickWand-config... Doesn't exist
checking Testing /usr/bin/MagickWand-config... Doesn't exist
checking Testing /usr/sbin/bin/MagickWand-config... Doesn't exist
checking Testing /opt/bin/MagickWand-config... Doesn't exist
checking Testing /opt/local/bin/MagickWand-config... Doesn't exist
configure: error: not found. Please provide a path to MagickWand-config
or Wand-config program.
ERROR: `/var/tmp/imagick/configure --with-php-config=/bin/php-config
--with-imagick' failed

Is there a way to manually get ImageMagick, ImageMagick-devel and PECL Imagick installed on RHEL 8 (NOT Gmagick)

EDIT

# dnf repolist
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:00:17 ago on Fri 28 Feb 2020 20:58:19 UTC.
repo id                                                                        repo name                                                                                                              status
*epel                                                                          Extra Packages for Enterprise Linux 8 - x86_64                                                                         4,916
*epel-modular                                                                  Extra Packages for Enterprise Linux Modular 8 - x86_64                                                                     0
remi-modular                                                                   Remi's Modular repository for Enterprise Linux 8 - x86_64                                                                 16
remi-safe                                                                      Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                                                             2,133
rhel-8-appstream-rhui-rpms                                                     Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs)                                                     8,566
rhel-8-baseos-rhui-rpms                                                        Red Hat Enterprise Linux 8 for x86_64 - BaseOS from RHUI (RPMs)                                                        3,690
rhui-client-config-server-8                                                    Red Hat Update Infrastructure 3 Client Configuration Server 8                                                              6
rpmfusion-free-updates                                                         RPM Fusion for EL 8 - Free - Updates
# yum install ImageMagick-devel
Error:
 Problem: conflicting requests
  - nothing provides jasper-devel needed by ImageMagick-devel-6.9.10.86-1.el8.x86_64
  - nothing provides OpenEXR-devel needed by ImageMagick-devel-6.9.10.86-1.el8.x86_64
  - nothing provides ghostscript-devel needed by ImageMagick-devel-6.9.10.86-1.el8.x86_64
  - nothing provides lcms2-devel needed by ImageMagick-devel-6.9.10.86-1.el8.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

SOLVED - https://www.imagemagick.org/script/install-source.php#unix

$ cd ImageMagick-7.0.9-26
$ ./configure
$ make
$ make install
$ sudo ldconfig /usr/local/lib
$ pecl install imagick
$ nano /etc/php.ini
// Add the following
extension=imagick.so

Works after removing Gmagick

Clean try with

$ sudo dnf install ImageMagick
$ dnf install php73-php-pecl-imagick
# php --ini | grep 'Loaded Configuration File'
PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib64/php/modules/imagick.so (/usr/lib64/php/modules/imagick.so: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/imagick.so.so (/usr/lib64/php/modules/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Loaded Configuration File:         /etc/php.ini

# ls
bz2.so       curl.so  fileinfo.so  gettext.so  json.so      mysqli.so   pdo_mysql.so   phar.so   simplexml.so  sysvmsg.so  tokenizer.so  xml.so
calendar.so  dom.so   ftp.so       iconv.so    mbstring.so  mysqlnd.so  pdo.so         posix.so  sockets.so    sysvsem.so  wddx.so       xmlwriter.so
ctype.so     exif.so  gd.so        intl.so     mcrypt.so    opcache.so  pdo_sqlite.so  shmop.so  sqlite3.so    sysvshm.so  xmlreader.so  xsl.so

nothing shown in php -m for imagick

# php -v
PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib64/php/modules/imagick.so (/usr/lib64/php/modules/imagick.so: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/imagick.so.so (/usr/lib64/php/modules/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.3.5 (cli) (built: Apr 30 2019 08:37:17) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.5, Copyright (c) 1999-2018, by Zend Technologies

Answer

Danila Vershinin picture Danila Vershinin · Feb 28, 2020

It looks like you seek to install PHP imagick module while having Remi repos around. So why not install directly the packaged module in lieu of compiling it?

Instead of pecl install imagick you can do something like dnf install php74-php-pecl-imagick. The actual command depends on whether you want multiple PHP versions or replace the default one, use config wizard for a hint.

Then you will not need any -devel packages installed.

If for some reason you don't want to rely on a packaged install the PHP module and really want to compile, you need to enable CodeReady Builder repo:

sudo subscription-manager repos --enable "codeready-builder-for-rhel-8-*-rpms"