thinkphp 报错:Call to undefined function think\captcha\imagettftext()
2021-07-14文远技术博客743187
在安装完gd库后,发现操作图片出现 thinkphp 报错:Call to undefined function think\captcha\imagettftext() 这样的错误,这是因为gd库没有指定freetype库
解决方法
1下载解压
[root@VM-0-15-centos ~]# wget "http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2"
[root@VM-0-15-centos ~]# tar jxfv freetype-2.4.0.tar.bz2
进入freetype目录
[root@VM-0-15-centos ~]# cd freetype-2.4.0/
2编译安装
[root@VM-0-15-centos freetype-2.4.0]# ./configure --prefix=/usr/local/freetype
--prefix 指定安装目录
[root@VM-0-15-centos freetype-2.4.0]# make && make install
3、重新安装gd库
进入到gd库目录
[root@VM-0-15-centos ~]# cd php-7.4.13/ext/gd
如果安装过gd库先执行如下命令
[root@VM-0-15-centos gd]# make clean
安装gd库
[root@VM-0-15-centos gd]# phpize
[root@VM-0-15-centos gd]# ./configure --with-freetype=/usr/local/freetype --with-php-config=/usr/local/php/bin/php-config
[root@VM-0-15-centos gd]# make && make install
注意,PHP7.4版本以后 --with-freetype=您的路径,以前--with-freetype-dir=您的路径
--with-php-config=您的PHP安装路径/bin/php-config
如果出现安装位置,那么说明安装成功
4、开启gd库
修改php.ini文件
extension=gd
5、重启php-fpm
重启之后运行如下命令查看是否成功开启
[root@VM-0-15-centos gd]# php -m
完成!
相关文章
文章评论
看完文章了吗?谁便说点吧
发表
暂无评论