Call to undefined function imagettftext()解决方法,calltoundefined
Call to undefined function imagettftext()解决方法,calltoundefined
老高在一个新环境中装DEDECMS的时候发现后台验证码无法显示。直接搜索一下这个错误,有人说session错误,有的说权限错误等等,这不胡扯么!只能看源代码了,定位到文件/include/vdimgck.php
。出错的函数是imagettftext()
,由于织梦使用了@
将错误隐去,导致这次莫名的错误。将@
去掉,错误立马出现:
<p>Fatal error: Call to undefined function imagettftext()</p>
现在我们就明确了,出现错误的原因是PHP编译时没有加上FreeType。
解决办法:
首先编译安装FreeType,以2.4.0为例:
<code class="hljs bash"><span class="hljs-built_in">wget http://download.savannah.gnu.org/releases/freetype/freetype-<span class="hljs-number">2.4.<span class="hljs-number">0.tar.bz2 <span class="hljs-built_in">tar -jxf freetype-<span class="hljs-number">2.4.<span class="hljs-number">0.tar.bz2 <span class="hljs-built_in">cd reetype-<span class="hljs-number">2.4.<span class="hljs-number">0 <span class="hljs-comment"># 安装到/usr/local/freetype ./configure --prefix=/usr/<span class="hljs-built_in">local/freetype <span class="hljs-built_in">make && <span class="hljs-built_in">make <span class="hljs-built_in">install </span></span></span></span></span></span></span></span></span></span></span></span></span></span></code>
下面我们重新编译PHP,加上参数--with-freetype-dir=/usr/local/freetype
<code class="hljs python">./configure \ <span class="hljs-prompt">... \ <span class="hljs-prompt">... \ --<span class="hljs-keyword">with-freetype-dir=/usr/local/freetype </span></span></span></code>
编译完成重启php
<code class="hljs coffeescript">kill -USR2 `<span class="javascript">cat /usr/local/php/<span class="hljs-keyword">var/run/php-fpm.pid` </span></span></code>
再GD库中找到FreeType Support
说明安装成功!
需要注意的是,如果服务器freetype的版本是1.*,那么你可能需要改变编译参数为--with-ttf[=DIR]
,以下转自ChinaUnix论坛:
<p>字库 配置开关<br />FreeType 1.x 要激活 FreeType 1.x 的支持,加上 --with-ttf[=DIR]。<br />FreeType 2 要激活 FreeType 2 的支持,加上 --with-freetype-dir=DIR。<br />T1lib 要激活 T1lib(Type 1 字体),加上 --with-t1lib[=DIR]。<br />本地 TrueType 字符串函数 要激活本地 TrueType 字符串函数的支持,加上 --enable-gd-native-ttf。</p>
参考:
http://bbs.chinaunix.net/thread-610205-1-1.html

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

SublimeText3漢化版
中文版,非常好用

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。