When Lao Gao installed DEDECMS in a new environment, he found that the background verification code could not be displayed. Search for this error directly. Some people say that the session is wrong, some say that the permissions are wrong, etc. Isn’t this nonsense! You can only view the source code and locate the file /include/vdimgck.php
. The error function is imagettftext()
. Because Dreamweaver used @
to hide the error, this inexplicable error occurred. Remove @
and the error will appear immediately:
<p>Fatal error: Call to undefined function imagettftext()</p>
Now we know clearly that the reason for the error is that FreeType was not added when PHP was compiled.
Solution:
First compile and install FreeType, taking 2.4.0 as an example:
<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>
Next we recompile PHP and add parameters --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>
Restart php after compilation
<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>
Find FreeType Support
in the GD library, indicating that the installation is successful!
It should be noted that if the server freetype version is 1.*, then you may need to change the compilation parameters to --with-ttf[=DIR]
. The following is reproduced from ChinaUnix Forum:
<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>
Reference:
http://bbs.chinaunix.net/thread-610205-1-1.html