美文网首页
Mac 自带 PHP 无 imagettftext 函数

Mac 自带 PHP 无 imagettftext 函数

作者: djyuning | 来源:发表于2017-11-23 12:39 被阅读556次

thinkphp 验证码在 macOS Sierra 10.12 上无法显示,提示下面的错误:

Call to undefined function think\captcha\imagettftext()

或:

Call to undefined function Think\imagettftext()

首先确定该问题为缺失 FreeType 扩展引起的,查看系统信息(phpinfo),找到 gd 项,查看有无 `` 四项,如无,说明 FreeType 未安装或未完整安装。

解决方案一:https://php-osx.liip.ch 一句话脚本(One Line Installation)

为系统 GD 库安装 FreeType 解决问题,打开终端输入:

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6

这里的 5.6 对应本机的 PHP 版本

终端自动执行,根据网速稍微缓慢~

$ curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
****
[WARNING]
Detected macOS Sierra 10.12. As this is quite new, there may be issues still. Your mileage may vary.
****
Get packager.tgz
Unpack packager.tgz
Please type in your password, as we want to install this into /usr/local
Password:
Start packager (may take some time)
downloading https://s3-eu-west-1.amazonaws.com/php-osx.liip.ch/install/5.6-10.10-frontenddev-latest.dat
downloading https://s3-eu-west-1.amazonaws.com/php-osx.liip.ch/install/5.6-10.10/frontenddev/5.6-10.10-frontenddev-5.6.27-20161101-100213.tar.bz2

安装成功,重启 Apache 服务:

$ sudo apachectl restart

参考文章

相关文章

网友评论

      本文标题:Mac 自带 PHP 无 imagettftext 函数

      本文链接:https://www.haomeiwen.com/subject/tkhnuttx.html