call to undefined function imagettftext()解决方法,calltoundefined由 老高 发表于 2014-10-03 在 代码人生 分类老高在一个新环境中装dedecms的时候发现后台验证码无法显示。直接搜索一下这个错误,有人说session错误,有的说权限错误等等,这不胡扯么!只能看源代码了,定位到文件/include/vdimgck.php。出错的函数是imagettftext(),由于织梦使用了@将错误隐去,导致这次莫名的错误。将@去掉,错误立马出现:
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.bz2tar -jxf freetype-2.4.0.tar.bz2cd reetype-2.4.0# 安装到/usr/local/freetype./configure --prefix=/usr/local/freetypemake && 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。
参考:
http://bbs.chinaunix.net/thread-610205-1-1.html
http://www.bkjia.com/phpjc/1110532.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/1110532.htmltecharticlecall to undefined function imagettftext()解决方法,calltoundefined 由老高发表于2014-10-03 在代码人生分类 老高在一个新环境中装dedecms的时候发现后台验...