由于wordpress建议安装imagick,而它默认没有加入到php源码中,于是记录一下自己编译安装imagick扩展的过程:
wget https://pecl.php.net/get/imagick-3.4.4.tgz
tar -xvf imagick-3.4.4.tgz && cd imagick-3.4.4
/usr/local/opt/php@7.4/bin/phpize
# 这个目录似乎没用到
mkdir /usr/local/opt/imagick
./configure --prefix=/usr/local/opt/imagick --with-php-config=/usr/local/opt/php@7.4/bin/php-config
报错:
checking ImageMagick MagickWand API configuration program... checking Testing /usr/local/bin/MagickWand-config... Doesn't exist
checking Testing /usr/bin/MagickWand-config... Doesn't exist
checking Testing /usr/sbin/bin/MagickWand-config... Doesn't exist
checking Testing /opt/bin/MagickWand-config... Doesn't exist
checking Testing /opt/local/bin/MagickWand-config... Doesn't exist
configure: error: not found. Please provide a path to MagickWand-config or Wand-config program.
解决办法:
yum install -y ImageMagick-devel
最后:
make && make install
vi /usr/local/etc/php/7.4/php.ini
# 在最后加入:
extension=imagick.so
# 查看是否OK:
/usr/local/opt/php@7.4/bin/php -m | grep imagick
重启php-fpm生效:
systemctl restart php-fpm@7.4