PHP Fatal error: Call to undefined function imagettfbbox()

在测试机上装了 yiiframework 玩了玩,没想到验证码显示不出来。
PHP 错误日志:

PHP Fatal error: Call to undefined function imagettfbbox() in …

php -m 发现 GD 已经编译进去了,而 freetype 在编译配置时也加了 –with-freetype-dir 。
不得其解,重新运行下编译配置看看:

./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr –with-mysqli=/usr/bin/mysql_config –enable-fpm –enable-sockets –enable-pdo –with-pdo-mysql=/usr –with-gd –with-jpeg-dir –with-png-dir –with-freetype-dir –with-zlib

配置输出:

checking for GD support… yes
checking for the location of libjpeg… yes
checking for the location of libpng… yes
checking for the location of libXpm… no
checking for FreeType 2… yes
checking for T1lib support… no
checking whether to enable truetype string function in GD… no
checking whether to enable JIS-mapped Japanese font support in GD… no
checking for fabsf… (cached) yes
checking for floorf… (cached) yes

注意其中有一行“whether to enable truetype string function in GD… no”,应该就是这个问题了吧。
加上 –enable-gd-native-ttf,重新编译并重启 PHP-FPM,问题依旧……

最后把 GD 相关的选项全选上了:

./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr –with-mysqli=/usr/bin/mysql_config –enable-fpm –enable-sockets –enable-pdo –with-pdo-mysql=/usr –with-gd –with-jpeg-dir –with-png-dir –with-xpm-dir –with-freetype-dir –with-t1lib –enable-gd-native-ttf –with-zlib

问题依旧!

……没折,该不会编译过程又抽风了吧。
清空,并重新编译:

make clean
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr –with-mysqli=/usr/bin/mysql_config –enable-fpm –enable-sockets –enable-pdo –with-pdo-mysql=/usr –with-gd –with-jpeg-dir –with-png-dir –with-freetype-dir –with-zlib
make && make install

问题解决了,感谢党和人民的支持!

更多PHP安装过程请参考:《Gentoo 下搭建 Nginx+ MySQL + PHP (fastcgi) 环境》

— EOF —

11 thoughts on “PHP Fatal error: Call to undefined function imagettfbbox()”

  1. 你好,我最近在将网站转移至nginx+fastcgi。也遇到验证码无法显示的问题,查看phpinfo()明明已经加载了GD模块,百思不得其解。重新编译PHP,运行之,验证码仍然无法显示,查看日志直接是
    WARNING: [pool www] child 3496 exited on signal 11 (SIGSEGV) after 4104 seconds from start
    请问你知道是什么原因吗?

发表评论

电子邮件地址不会被公开。 必填项已用*标注