> ## Content Index
> Fetch the complete content index at: https://sgpublic.xyz/llms.txt
> Use this file to discover other available public pages before exploring further.

# php7 安装 imagick 扩展
- URL: https://sgpublic.xyz/p/2021/05/6aac9cb1810a4800015335e9/
- Published: 2021-05-09T06:32:25.000Z
- Updated: 2026-09-18T04:59:26.000Z
- Author: Haven Madray
- Tags: 软件开发, #wp-post

> 转自 [php7安装imagick扩展 - 吴昊博客 (whsir.com)](https://blog.whsir.com/post-4736.html?ref=sgpublic.xyz)

适用于Centos6.x和Centos7.x系统，php使用7.1版本，[wlnmp一键包已支持该扩展](https://blog.whsir.com/post-3647.html?ref=sgpublic.xyz)

imagick扩展包地址：[https://pecl.php.net/package/imagick](https://pecl.php.net/package/imagick?ref=sgpublic.xyz)

### 安装所需依赖

如果在编译时还提示缺少其他依赖，请自行安装

```

yum install autoconf gcc gcc-c++ ImageMagick-devel
```

### 下载imagick最新稳定版

```
wget https://pecl.php.net/get/imagick-3.4.4.tgz
tar xf imagick-3.4.4.tgz
cd imagick-3.4.4
/usr/local/php/bin/phpize
```

根据自己phpize的位置来运行即可（不知道phpize在哪的直接find / -name phpize查找），运行完提示下面信息，然后编译

```
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
```

### 编译扩展模块

```
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
```

执行完成后会显示扩展模块编译到的目录/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/

### 修改php.ini添加扩展

```
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/"
extension=imagick.so
```

注意：如果之前配置过extension\_dir路径了，则只需要配置extension=imagick.so即可

保存退出，重启php

通过phpinfo可看到，扩展已生效

![](https://sgpublic.xyz/content/images/2026/09/php_imagick.png)