linux重新編譯安裝gd,增加freetype支持,解決驗證碼不顯示問題,Fatal error: Call to undefined function imagettftext()

問題:

Fatal error: Call to undefined function Think\imagettftext() in /var/www/webreg/ThinkPHP/Library/Think/Verify.class.php on line 143

查看phpinfo()後得知,gd中沒有freetype的支持

解決:

首先安裝freestyle,php-gd

確保先安裝freestyle,然後是php-gd;如果是先安裝了php-gd,那麼在安裝完freestyle後,需要make clean(這句很重要,弄了很多此,,,在這)

然後重新配置編譯參數如下: 

1.到【你的php源碼解壓目錄】/ext/gd

make clean
./configure 
--with-mysql 
--prefix=/homewww/php 
--with-apxs2=/homewww/httpd/bin/apxs 
--with-config-file-path=/homewww/php/conf 
--with-gd --enable-exif 
--enable-gd-native-ttf 
--enable-inline-optimization 
--with-zlib --with-png-dir 
--with-jpeg-dir=/usr/local/jpeg 
--with-freetype-dir=/usr/local/lib 
--with-ttf 
--enable-mbstring 
--with-gettext 
--enable-gd-jis-conv
make && make install
2. 成功後提示如下,
Installing shared extensions:     /homewww/php/lib/php/extensions/no-debug-zts-20100525/
這樣新編譯的gd.so會在此路徑下,需要cp到你的php.ini中配置的extension_dir的目錄下即可。
3.以apache爲例,重啓 apache,service httpd restart 
4.另外,也有可能是libjpeg libpng zlib這些引起,按提示安裝後編譯進去即可。  這些依賴庫包括freetype ,php-gd可通過yum install方式安裝



好久沒記錄東西了,希望能幫到後來遇到問題的朋友。。。




----------------附上完整php編譯參數:------------------------------------------------------------------------------------------------------------------------------------------

./configure \
--prefix=/homewww/php \
--with-apxs2=/homewww/httpd/bin/apxs \
--with-config-file-path=/homewww/php/conf \
--with-mysql \
--with-mysqli \
--with-mysql-sock \
--enable-pdo \
--with-pdo-mysql \
--with-gd \
--with-iconv  \
--with-zlib \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-gd-native-ttf \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-jpeg-dir=/usr/local/jpeg \
--with-freetype-dir \
--with-png-dir=/usr/local/pngp \
--with-bz2 \





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章