Jump to content
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
NickTheGreek

cPanel EasyApache 4 Installing Imagemagick and imagick PHP extension - fixed

Recommended Posts

I found a nice clean guide for imagick PHP through SSH here:

 

https://help.bigscoots.com/en/articles/730428-cpanel-easyapache-4-installing-imagemagick-and-imagick-php-extension

 

cPanel EasyApache 4 Installing Imagemagick and imagick PHP extension

This is a quick guide on how to install both the imagick PHP extension as well as the application via SSH.
 
Written by Justin Catello
Updated over a week ago

This is fairly simple, just copy and paste the following into SSH.

1. Installing imagemagick:

yum -y install ImageMagick-devel ImageMagick-c++-devel ImageMagick-perl

2. Installing the imagemagick PHP extensions for all installed PHP versions.

for phpver in $(whmapi1 php_get_installed_versions|grep -oE '\bea-php.*') ; do
printf "\autodetect" | /opt/cpanel/$phpver/root/usr/bin/pecl install imagick
echo 'extension=imagick.so' >> /opt/cpanel/$phpver/root/etc/php.d/imagick.ini
done
/scripts/restartsrv_httpd
/scripts/restartsrv_apache_php_fpm

3.  Test to make sure imagemagick is installed:

/usr/bin/convert --version

4. Test to make sure the PHP extensions loaded:

for phpver in $(whmapi1 php_get_installed_versions|grep -oE '\bea-php.*') ; do
echo "PHP $phpver" ; /opt/cpanel/$phpver/root/usr/bin/php -m |grep imagick
done
PHP 54
imagick
PHP 55
imagick
PHP 56
imagick
PHP 70
imagick
PHP 71
imagick

 

 

Problem with this guide is this command:

 

echo 'extension=imagick.so' >> /opt/cpanel/$phpver/root/etc/php.d/imagick.ini
done

 

We noticed with our colleagues in angellight.com it causes duplicate SO entries in:

php.d/zzzzzzz-pecl.ini:extension="imagick.so"
php.d/imagick.ini:extension=imagick.so

as it shows here:

https://support.cpanel.net/hc/en-us/articles/360052373474-Severity-Core-Warning-Module-imagick-already-loaded-Unknown-0

 

Symptoms

 

 You see these errors appearing in PHP's log files: 
 

ERROR - 17/08/2020 18:48:48 --> Severity: Core Warning --> Module 'imagick' already loaded Unknown 0
ERROR - 17/08/2020 18:48:48 --> Severity: Core Warning --> Module 'imagick' already loaded Unknown 0
ERROR - 17/08/2020 18:48:49 --> Severity: Core Warning --> Module 'imagick' already loaded Unknown 0
ERROR - 17/08/2020 18:48:49 --> Severity: Core Warning --> Module 'imagick' already loaded Unknown 0
ERROR - 17/08/2020 18:48:49 --> Severity: Core Warning --> Module 'imagick' already loaded Unknown 0

 

Description

 

This usually means that the module has been loaded more than one time i.e. there are at least two instances of the directive that loads the module in PHP's configuration files. This can occur when the module has been installed multiple times using different utilities (yum, pecl, etc). In our case the directive looks like this: 

 

extension="imagick.so"

 

Workaround

 

First, we need to identify what PHP version the domain (AKA VHost) is using. You can run this command to confirm the PHP version the domain is assigned to:  

 

uapi --user=$USER LangPHP php_get_vhost_versions | egrep -i domain -A 1


Here $USER must be replaced with the name of the user the domain belongs to. The output looks like this: 

 

uapi --user=cptest LangPHP php_get_vhost_versions | egrep -i domain -A 1

 domain: foo.testing.com
 version: ea-php72
--
 domain: sub.cptest.net
 version: ea-php72
--
 domain: foo1.bar1.com
 version: ea-php72

 

You will see the PHP version each domain is using listed underneath the domain name. Now you need to go to this location:

 

cd /opt/cpanel/ea-php##/root/etc

 

Don't forget to change the PHP version (ea-php##) in the above path with the domain's PHP. And now if you recursively search for the module-loading directive from above, you should see more than one line showing up: 

 

grep -ir imagi *

php.d/zzzzzzz-pecl.ini:extension="imagick.so"
php.d/imagick.ini:extension=imagick.so

 

You need to edit one of these files and comment out the line where the directive appears and then restart the PHP-FPM service from the WHM > Restart Services > PHP-FPM service for Apache interface. The error messages should now disappear.  

 

 

 

 

 

Share this post


Link to post
Share on other sites

we decided to automate the whole process so we did this:

CHECK
=====
find /opt/cpanel/* -name zzzzzzz-pecl.ini -exec grep -Hn  "imag" {} \;

find /opt/cpanel/* -name imagick.ini -exec grep -Hn  "imag" {} \;

FIX
=====
find /opt/cpanel/* -name imagick.ini -exec sed -i 's/extension=imagick.so/;extension=imagick.so/' {} \;


/scripts/restartsrv_httpd
/scripts/restartsrv_apache_php_fpm

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×