This article provides a guide for how to install ImageMagick on cPanel WHM server. This guide is intended for root-level cPanel VPS or cPanel Dedicated Server administrator.
What is ImageMagick?
ImageMagick is a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images.
Since 1987, ImageMagick has become a signature open-source image-editing software, used as both a stand-alone project as well as an ancillary package, bundled with other popular softwares. As such, the ImageMagick package is considered a dependency of many common website softwares, such as WordPress and WHMCS. Therefore, it may be helpful to install on cPanel WHM servers.
Install ImageMagick on cPanel WHM Server
You can install ImageMagick to cPanel/WHM servers per PHP version or for all PHP versions.
Install ImageMagick on cPanel/WHM Server for Specific PHP Versions
To install ImageMagick to a cPanel/WHM server for specific PHP version, perform the following steps:
- SSH the server as root user
- Run the following command to install the ImageMagick packages from RPM:
yum install ImageMagick ImageMagick-devel -y
- Find the binaries for PECL for all versions of PHP that you have installed:
find /opt/cpanel/ -iname pecl | grep bin
- Check the output to confirm PECL binaries of the cPanel installation:
root@cpanel [~]# find /opt/cpanel/ -iname pecl | grep bin
where ea-phpXX represents the installed PHP versions.
/opt/cpanel/ea-php71/root/usr/bin/pecl
/opt/cpanel/ea-php72/root/usr/bin/pecl
/opt/cpanel/ea-php73/root/usr/bin/pecl
/opt/cpanel/ea-php74/root/usr/bin/pecl
/opt/cpanel/ea-php80/root/usr/bin/pecl
/opt/cpanel/ea-php81/root/usr/bin/pecl
/opt/cpanel/ea-php82/root/usr/bin/pecl
/opt/cpanel/ea-php83/root/usr/bin/pecl
root@cpanel [~]# - For each PHP version, run the following command (modify the commands for the PHP versions):
/opt/cpanel/ea-phpXX/root/usr/bin/pecl install imagick
- Example commands:
printf "\n" | /opt/cpanel/ea-php71/root/usr/bin/pecl install imagick
printf "\n" | /opt/cpanel/ea-php72/root/usr/bin/pecl install imagick
printf "\n" | /opt/cpanel/ea-php73/root/usr/bin/pecl install imagick
printf "\n" | /opt/cpanel/ea-php74/root/usr/bin/pecl install imagick
printf "\n" | /opt/cpanel/ea-php80/root/usr/bin/pecl install imagick
printf "\n" | /opt/cpanel/ea-php81/root/usr/bin/pecl install imagick
printf "\n" | /opt/cpanel/ea-php82/root/usr/bin/pecl install imagick
printf "\n" | /opt/cpanel/ea-php83/root/usr/bin/pecl install imagick - After each command, confirm the prefix of ImageMagick installation (enter "Return" to use default):
Please provide the prefix of ImageMagick installation [autodetect] :
- Repeat for each PHP version
Install ImageMagick on cPanel/WHM Server for All PHP Versions
To install ImageMagick to a cPanel/WHM server for all PHP versions (installed and configured in EasyApache), follow the steps below:
- SSH the server as root user
- Run the following command to install the packages AND configure enable PHP extensions for all possible PHP versions:
yum -y install ImageMagick-devel ImageMagick-c++-devel ImageMagick-perl for php in $(whmapi1 php_get_installed_versions|grep -oE '\bea-php.*') ; do /opt/cpanel/$php/root/usr/bin/pecl install imagick; done
- After each command, confirm the prefix of ImageMagick installation (enter "Return" to use default):
Please provide the prefix of ImageMagick installation [autodetect] :
- Repeat for each PHP version
Conclusion
You have now installed ImageMagick on cPanel/WHM server. If you face any difficulties, please open a support ticket for assistance.