报错的原因是php中gd库的相关图片能力没有正确开启和引用
通过phpInfo()查看 gd库已经开启,但是里边没有freeType 和jpeg的支持 但有png的支持
1、如果是 freetype 跟 jpeg没有安装
则安装这两软件
yum install freetype*
yum install libjpeg*
安装之后寻找安装路径find / -name freetype
结果在 /usr/include/freetype2/ 文件夹中
同理 libjpeg 在 /usr/include 中
2、进入php源代码的 php源代码(下载的代码)/ext/gd文件夹中 利用phpize进行拓展安装
初始化php组件安装环境:/usr/local/php/bin/phpize
配置gd编译环境:./configure --with-freetype-dir=/usr/include/freetype2 --enable-gd-native-ttf --with-jpeg-dir=/usr/include --with-php-config=/usr/local/php/bin/php-config 注意加粗部分,不加这个还是没有开启freetype能力,仍然会报imagettftext函数不存在的错误(第一次没有加这个配置,编译安装gd后还是报错)
编译:make
安装:make install
[root@shop2 gd]# make install
Installing shared extensions: /usr/local/php5.6.36/lib/php/extensions/no-debug-non-zts-20131226/
Installing header files: /usr/local/php5.6.36/include/php/
[root@shop2 gd]# cd /usr/local/php5.6.36/lib/php/extensions/no-debug-non-zts-20131226/
[root@shop2 no-debug-non-zts-20131226]# ll
-rwxr-xr-x 1 root root 1401784 Nov 13 16:40 gd.so
安装后到安装的目录查看一下,重启php-fpm,再看phpinfo(),则有完整的gd各个图片库能力了,主要是红框部分
再运行程序也不会再报imagettftext函数不存在的错误了
参考学习链接:https://blog.youkuaiyun.com/u014062332/article/details/25633647
https://blog.youkuaiyun.com/kocscs123/article/details/76549496