转自:https://blog.csdn.net/qq_16885135/article/details/78130281
1.从 https://pecl.php.net/package/imagick 下载源码包,并解压
2.phpize
提示:
#The program 'phpize' is currently not installed. You can install it by typing: sudo apt install php7.0-dev
使用 sudo apt install php7.0-dev
安装 php7.0-dev 后
phpize Configuring for: PHP Api Version: 20151012 Zend Module Api No: 20151012 Zend Extension Api No: 320151012
3. 进入解压后的目录,执行 ./configure
报错1:
checking for pkg-config... no pkg-config not found configure: error: Please reinstall the pkg-config distribution
使用 sudo apt-get install pkg-config
安装 pkg-config 后成功解决报错1.
重新执行 ./configure
报错2:
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.
使用 sudo apt-get install libmagickwand-dev libmagickcore-dev
安装 libmagickwand-dev 和 libmagickcore-dev 成功解决报错2。
此后 ./configure
顺利执行完成。
4. sudo make && sudo make install
顺利安装完成
最后两行:
Installing shared extensions: /usr/lib/php/20151012/ Installing header files: /usr/include/php/20151012/
此时可以在 /usr/lib/php/20151012/
目录下看到 imagick.so 文件。
cd /etc/php/7.0/mods-available/ sudo vim imagick.ini 填入:'extension=imagick.so' 并保存 cd /etc/php/7.0/fpm/conf.d sudo ln -s /etc/php/7.0/mods-available/imagick.ini 20-imagick.ini
重启 php-fpm