PHP Warning: Module 'imagick' already loaded in Unknown on line 0
I have a simple test file where the only php codes are:
if (isset($_REQUEST['back']) &开发者_开发知识库amp;& ($back != '')) { $back = $_REQUEST['back']; }
$filename = 'images/'.$back.'.jpg';
$file = (file_exists($filename)) ? $back : 'back1';
Now each time I run the file, I get this line added PHP Warning: Module 'imagick' already loaded in Unknown on line 0
in my error log. Any suggestion please ?
open your php.ini file and comment this
;extension=imagick.so
this resolved my problem
make sure you just actived imagick just once.
if windows:
active extension=php_imagick.dll
and comment/remove like ;extension=imagick
follow this tutorial
extension=imagick.so
did not exist in my php.ini, so I solved it by re-installing imagick (3.4.4)
using WHM under Home >> Software >> Module Installers - "PHP Pecl" Installer.
No more errors (so far).
Just for the record as it might help others who are on shared hosting (cPanel).
I had error on shared hosting php7.2: Module 'imagick' already loaded in Unknown on line 0
In the beginning hosting provider said it was my bad configuration (running Yii2.16). But after I showed them, that all Internet related this issue to server configuration -they started to listen to me. After I proved, that there was no error on php7.1 they started to search for the error.
They confirmed, that they updated (before error) 7.2 to new version (7.2.14), what fixed some other bugs, but Imagick error started to appear. Now they found fix to that also. As they told to me - the error was in configuration of PERL modules or PEAR package, but they did not tell me the real issue.
Solution, if you are on shared hosting - talk to you provider and experiment with PHP versions (if you can change them).
These libraries may also be loaded using ini files in /etc/php.d. Be sure it is not in a file here AND in php.ini.
I don'n know why, but I had two imagick.ini files in /etc/php.d/
# ls -l /etc/php.d/*imag*
-rw-r--r--. 1 root root 21 15. Aug 11:46 /etc/php.d/20-imagick.ini
-rw-r--r--. 1 root root 530 12. Jan 2022 /etc/php.d/40-imagick.ini
I commented out one
extension=imagick.so
line in one of these files and the error was gone.
After installing the imagick extension for PHP. When i perform php-fpm -v
, I had the same problem, as follows:
[root@localhost]# php-fpm -v
[10-Oct-2018 16:00:33] NOTICE: PHP message: PHP Warning: Module 'imagick' already loaded in Unknown on line 0
Because i created echo extension=imagick.so >> php.ini
and echo extension=imagick.ini
manually when i installed the imagick extension for PHP. I will delete imagick.ini
now, restart php. It's solve!
By tedious moments about this problem, I've found a solution that might be able to repair a system if you tried to uninstall and install ImageMagick with PECL and also having sort of problems here with the imagick.so file. ! Because of dumbly "source installing" on a server with CPanel to actually get WebP support.
But you don't need to replicate my way down below maybe all you only need to do:
Is actually to reinstall this module in EasyApache 4 as of speaking:
mod_lsapi
After you reinstall the mod you will be able to reset the php.ini files by that module in the system. Then it is easy to wait for another full error_log which likely wouldn't happen from now.
Option 2:
I've tried to remove all rpm with yum and even PECL uninstall and used ImageMagick as source files that installed the whole system wrong at the beginning. It's hard for the ImageMagick source to find the right place to put the imagick.so file in the extension folder. As it is in another directory with CPanel:
/opt/cpanel/ea-php74/root/usr/lib64/php/modules
You might want to uninstall all .rpm with "!Important that only if you already made that from source in your Cpanel system." That is only when you have tried source install.
yum remove ImageM*
And install from source Imagick. If you can't do it make ImageMagick from source with enabling shared. Also, you will have to remove the module ImageMagick from PECL after making a source install. And make sure imagick.so is still in this directory when the module is still installed with PECL before you uninstall and use source version of ImageMagick:
cp /opt/cpanel/ea-php74/root/usr/lib64/php/modules/imagick.so /root/tmp
cp /root/tmp/imagick.so /opt/cpanel/ea-php74/root/usr/lib64/php/modules
To find your own module folder use:
php -i | grep extension_dir
Remember I've used the php74 version and with CPanel, as this problem only exists for these users of CPanel or users with php74 in a different location. And use the right PHP version instead of php74.
To make the shared enable install ImageMagick source correctly by:
./configure --enable-shared
make
make install
精彩评论