---
title: "macos 安装imagick解决php不能显示验证码的问题"
author: "haohetao"
date: "2018-11-04T04:15:02Z"
tags: []
categories: ["操作系统"]
slug: "macos-imagick-php"
draft: false
lastmod: "2018-11-04T05:35:31Z"
id: 2433197
url: "https://haohetao.iteye.com/blog/2433197"
---

需要选安装pear,然后用pecl install imagick来安装imagick
macos开启了rootless无法向系统目录写入文件，所以要先关闭rootless
curl -O http://pear.php.net/go-pear.phar
sudo php -d detect_unicode=0 go-pear.phar
brew install autoconf pcre
sudo pecl install imagick
最后加extension=imagick.so到php.ini中

pecl如果提示找不到imagick发行，就换个网络或者使用跳板
我是把pear安装到/usr/local中了，但是imagick必须安装到/usr/lib中，所以最后还是把rootless关了

另一种方法是使用brew install php,而不是用mac os自带的php，其实推荐这种方法，不用修改系统目录，不用关闭rootless
apache加载的方法是
LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so

最后最好把rootless再加打

也可以用这上面的方法安装php
https://php-osx.liip.ch/
我用brew install php是有问题的，最后用的是liip安装的php