cPanel libMagickWand.so.2 PHP Extension Error after UPCP Update

Centos:     6.7
WHM:        11.50.0
Apache:     2.2.39
PHP:        5.4.42

I awoke today to find all websites hosted on one particular cPanel server showing the following message at the bottom of every web page.

 

Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-xxxxxxx/imagick.so' – libMagickWand.so.2: cannot open shared object file: No such file or directory in Unknown on line 0

 

libMagickWand.so.2 didnt seem to exist anywhere on the server now. Looking in /usr/lib64 I could see the following files:

lrwxrwxrwx.  1 root root       22 Aug  7 00:23 libMagickCore.so -> libMagickCore.so.5.0.0*
lrwxrwxrwx.  1 root root       22 Aug  7 00:23 libMagickCore.so.5 -> libMagickCore.so.5.0.0*
-rwxr-xr-x.  1 root root  2491240 Jul 23 23:53 libMagickCore.so.5.0.0*
lrwxrwxrwx.  1 root root       20 Aug  7 00:23 libMagick++.so -> libMagick++.so.5.0.0*
lrwxrwxrwx.  1 root root       20 Aug  7 00:23 libMagick++.so.5 -> libMagick++.so.5.0.0*
-rwxr-xr-x.  1 root root   451304 Jul 23 23:53 libMagick++.so.5.0.0*
lrwxrwxrwx.  1 root root       22 Aug  7 00:23 libMagickWand.so -> libMagickWand.so.5.0.0*
lrwxrwxrwx.  1 root root       22 Aug  7 00:23 libMagickWand.so.5 -> libMagickWand.so.5.0.0*
-rwxr-xr-x.  1 root root  1167744 Jul 23 23:53 libMagickWand.so.5.0.0*

 

Firstly I tried to re-install ImageMagick

# /scripts/installimagemagick

This should reinstall the ImageMagick provided by the yum repositories and automatically link it to Apache/PHP

 

This did not solve the problem so I used the following procedure:

# mv /usr/local/lib/php.ini /usr/local/lib/php.ini-original

# /scripts/phpini

The /scripts/phpini script builds the php.ini configuration file based on the options selected during EasyApache and Pear/Pecl selections.

Note: If you have customised your php.ini for third-party applications, modules or personalised settings (i.e.. different time zones, enabling/disabling standard functions), you will need to replace those customizations – which is why the original php.ini was saved as php.ini-original

 

This sadly completely broke a few websites as PDO was not showing as installed as a PHP module (run php -m to get the installed modules)

 

The next step was to rebuild Apache using EasyApache. To do this from the command line run:

 

# /scripts/easyapache --build

This rebuilds Apache and PHP based on the current selections (eg the ticked boxes in the GUI )

 

It appeared that a upcp (cPanel update which can also include a yum system update) job ran overnight and updated the version of ImageMagick from the yum repositories. As php.ini requires either an EasyApache or /scripts/phpini to update, the ImageMagick installation referenced in the in the php.ini was no longer valid.