When using EA-PHP, (cPanel provided PHP) the ImageMagick PHP PECL extension uses the ImageMagick RPM package that is provided by the CentOS repository. This CentOS provided ImageMagick package is not compiled with webp support, so it is not possible to use the webp format with ImageMagick and EA-PHP in an officially supported way.
This guide provides the steps required to make use of the ImageMagick RPM package that is provided by the Remi Repository instead, which has been compiled with webp support.
When using the version of ImageMagick provided with ALT-PHP, you'll find that the webp image format is already enabled and working. If you're using ALT-PHP, you do not need to use this guide to enable the webp format.
If you do not specifically need to use ImageMagick, it is highly recommended that you make use of the GD library instead of ImageMagick for webp support. The GD library comes with webp support by default when using EA-PHP on CentOS 7.
The instructions in this guide were tested on the following environment:
Operating System: CentOS Linux release 7.9.2009 [ kvm ]
cPanel Version: 96.0.11 (RELEASE tier) (STANDARD profile)
IMPORTANT: DO NOT use this guide on a CentOS 8 server.
IMPORTANT: Use of packages from the Remi Repository is not supported by cPanel. This guide is provided as a courtesy only. Issues with the steps in this guide and problems arising from the use of this guide must be directed to a systems administrator with the skills, training, and experience required to troubleshoot the problem for you.
If you would like for cPanel to add support for the Remi Repository or for webp in ImageMagick so that this could be fully supported, please submit a feature request:
IMPORTANT: You should work with your systems administrator to ensure that the Remi Repository is disabled by default and that only the ImageMagick package would ever be installed from it. Installation of system packages from the Remi Repository instead of the default CentOS repository could cause unexpected and possibly unpleasant results if those packages were built in a way that is not compatible with cPanel.
IMPORTANT: If you have previously attempted to install ImageMagick via another method such as manual compilation and installation with the make utility, you must first uninstall that version of ImageMagick before continuing with the following instructions. Failure to properly remove previous install attempts may interfere with the operation of ImageMagick after following this guide. The process of troubleshooting this must be done by a systems administrator with the skills, training, and expertise required to do so for you.
- Login to your cPanel server via SSH or Terminal as the root user
- Remove the existing ImageMagick packages:
yum remove ImageMagick ImageMagick-devel
- Install the EPEL repository (Remi Repo Requirement):
yum install epel-release
- Install the Remi Repository:
wget https://rpms.remirepo.net/enterprise/remi-release-7.rpmNOTE: You'll notice that this step (#4) omits the download and install of the EPEL rpm that is shown in the Remi Repo installation instructions at the link above. It has been ommited because the EPEL repository has already been installed via yum in step #3 above.
rpm -Uvh remi-release-7.rpm
- As mentioned earlier in this article, disable the Remi Repository so that packages can only be explicitly installed from it:
yum-config-manager --disable remi-safe
- Install ImageMagick directly from the Remi Repository by enabling it only for this one transaction:
yum install --enablerepo=remi -y ImageMagick ImageMagick-devel
- Find the PECL binaries so that you can re-install or install the ImageMagick PHP Extensions:
find /opt/cpanel/ -iname pecl | grep bin
- For each desired PHP version, uninstall (if needed) and then install the ImageMagick PHP Extension. PHP 74 is used in this example:
/opt/cpanel/ea-php74/root/usr/bin/pecl uninstall imagickNOTE: When prompted for the ImageMagick prefix, just press enter to and allow it to autodetect.
/opt/cpanel/ea-php74/root/usr/bin/pecl install imagick
- If using CloudLinux and CageFS be sure to rebuild CageFS with the steps outlined in our guide:
How to rebuild CageFS
- Optionally create a PHP Info file to verify that the extension is enabled:
How to create a PHPInfo File
- Optionally create a test PHP script that will generate sample images (including webp format) and provide a list of supported image formats:
How to Show ImageMagick Supported Image Types via PHP and Generate Test Images For Common Image Formats