centos8出现php magick.so扩展读取错误的解决办法

php错误日志中出现: PHP Warning: PHP Startup: Unable to load dynamic lib
rary ‘imagick’ (tried: /usr/lib64/php/modules/imagick (/usr/lib64/php/modules/im
agick: cannot open shared object file: No such file or directory), /usr/lib64/ph
p/modules/imagick.so (/usr/lib64/php/modules/imagick.so: undefined symbol: insta
nceof_function_ex)) in Unknown on line 0

使用php -m|grep imagick命令,发现imagick未加载。

解决办法:

#yum install php-imagick

或者

#dnf install php-imagick

然后重启,systemctl restart httpd

#php -m|grep imagick

imagick

显示加载成功!

但在错误日志中显示:PHP Warning: Module “imagick” is already loaded in U
nknown on line 0
说明重复加载失败,在/etc/php.d目录下,发现有20-imagick.ini和40-imagick.ini文件,删除20-imagick.ini,重新启动httpd搞定!