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 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

MinGW - Windows용 미니멀리스트 GNU
이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

WebStorm Mac 버전
유용한 JavaScript 개발 도구

Dreamweaver Mac版
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)
