教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 解决Call to undefined function imagettftext()方法

解决Call to undefined function imagettftext()方法

发布时间:2017-10-25   编辑:jiaochengji.com
教程集为您提供解决Call to undefined function imagettftext()方法等资源,欢迎您收藏本站,我们将为您提供最新的解决Call to undefined function imagettftext()方法资源

在一个新环境中装Tipask v2.5的时候发现后台验证码无法显示。出错的函数是imagettftext(),由于index.php使用了error_reporting(0)将错误隐去,导致这次莫名的错误,去掉,错误立马出现:

Fatal error: Call to undefined function imagettftext()
现在我们就明确了,出现错误的原因是PHP编译时没有加上FreeType。

解决办法

首先编译安装FreeType,以2.4.0为例:

wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2
tar -jxf freetype-2.4.0.tar.bz2
cd reetype-2.4.0
# 安装到/usr/local/freetype
./configure –prefix=/usr/local/freetype
make && make install
下面我们重新编译PHP,加上参数–with-freetype-dir=/usr/local/freetype

./configure –with-freetype-dir=/usr/local/freetype
编译完成重启php

kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`
再GD库中找到FreeType Support说明安装成功!

需要注意的是,如果服务器freetype的版本是1.*,那么你可能需要改变编译参数为–with-ttf[=DIR],以下转自ChinaUnix论坛:

字库 配置开关
FreeType 1.x 要激活 FreeType 1.x 的支持,加上 –with-ttf[=DIR]。
FreeType 2 要激活 FreeType 2 的支持,加上 –with-freetype-dir=DIR。
T1lib 要激活 T1lib(Type 1 字体),加上 –with-t1lib[=DIR]。
本地 TrueType 字符串函数 要激活本地 TrueType 字符串函数的支持,加上 –enable-gd-native-ttf。

您可能感兴趣的文章:
解决Call to undefined function imagettftext()方法
Call to undefined function curl_init的解决办法
php中出现:Call to undefined function curl_init()的解决方法
windows下php开启curl_init的方法
php:Call to undefined function curl_init()的解决方法
php Fatal error: Call to undefined function mb_convert_encoding()
php连接mysql错误的配置方法介绍
Call to undefined method DebugBar\\DebugBar::info()
解决Magento报错:Fatal error: Call to undefined method
php提示:Call to undefined function curl_init

[关闭]
~ ~