Call to undefined function imagettftext()解決方案,calltoundefined
由 老高 發表於 2014-10-03 在 代碼人生 分類
老高在一個新環境中裝DEDECMS的時候發現後台驗證碼無法顯示。直接搜尋一下這個錯誤,有人說session錯誤,有的說許可權錯誤等等,這不胡扯麼!只能看原始碼了,定位到檔案/include/vdimgck.php。出錯的函數是imagettftext(),由於織夢使用了@將錯誤隱去,導致這次莫名的錯誤。將@去掉,錯誤立馬出現:
Fatal error: Call to undefined function imagettftext()
現在我們就明確了,出現錯誤的原因是PHP編譯時間沒有加上FreeType。
解決辦法:
首先編譯安裝FreeType,以2.4.0為例:
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2tar -jxf freetype-2.4.0.tar.bz2cd reetype-2.4.0# 安裝到/usr/local/freetype./configure --prefix=/usr/local/freetypemake && make install
下面我們重新編譯PHP,加上參數--with-freetype-dir=/usr/local/freetype
./configure \... \... \--with-freetype-dir=/usr/local/freetype
編譯完成重啟php
kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`
再GD庫中找到FreeType Support說明安裝成功!
需要注意的是,如果伺服器freetype的版本是1.*,那麼你可能需要改變編譯參數為--with-ttf[=DIR],以下轉自ChinaUnix論壇:
字型檔 配置開關
FreeType 1.x 要啟用 FreeType 1.x 的支援,加上 --with-ttf[=DIR]。
FreeType 2 要啟用 FreeType 2 的支援,加上 --with-freetype-dir=DIR。
T1lib 要啟用 T1lib(Type 1 字型),加上 --with-t1lib[=DIR]。
本地 TrueType 字串函數 要啟用本地 TrueType 字串函數的支援,加上 --enable-gd-native-ttf。
參考:
http://bbs.chinaunix.net/thread-610205-1-1.html
http://www.bkjia.com/PHPjc/1110532.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1110532.htmlTechArticleCall to undefined function imagettftext()解決方案,calltoundefined 由老高發表於2014-10-03 在代碼人生分類 老高在一個新環境中裝DEDECMS的時候發現後台驗...