PHP+GD庫添加freetype拓展使用詳解

來源:互聯網
上載者:User
這次給大家帶來PHP+GD庫添加freetype拓展使用詳解,PHP+GD庫添加freetype拓展的注意事項有哪些,下面就是實戰案例,一起來看一下。

linux版本 centos 6.6

安裝流程(由於伺服器為分布式內網伺服器,無法使用yum安裝,以下均為下載資源套件後的編譯安裝):

安裝freetype

解壓freetype-2.3.9.tar.gz

編譯安裝

./configure --enable-static --enable-shared (沒有指定prefix, .h檔案預設安裝到 /usr/local/include, .a|.so檔案預設安裝到 /usr/local/lib內 其他資源套件的安裝如果沒有指定目錄也是一樣到這個位置)

make && make install

確認freetype 安裝成功後重新編譯安裝GD庫,添加freetype 支援

安裝gd庫,版本2.0.35

由於之前有安裝記錄,建議先make clean ,否則可能導致安裝失敗

./configure --enable-shared --with-jpeg=/usr/local/include/ --with-freetype=/usr/local/ --with-png=/usr/local/include/(這裡要注意的是--with-freetype=/usr/local/的路徑一開始寫的是 /usr/local/lib,結果一直引入freetype失敗,估計因為標頭檔不在這個目錄內,改為上一級目錄後引入成功)

確認 Support for Freetype 2.x library: yes

make && make install

確認安裝成功後重新編譯安裝PHP的gd拓展

php版本5.5.38

單獨安裝gd拓展模組需要cd 到 php-5.5.38/ext/gd

執行 phpize 產生編譯檔案,如果系統沒有引入phpize,這個檔案在PHP安裝目錄下的bin中

在這裡一定要先執行make clean,這次安裝了8台伺服器,沒有先執行make clean的100%沒有安裝成功,都沒有添加到freetype support

./configure --with-php-config=/opt/php5.5.38/bin/php-config --with-jpeg-dir --with-png-dir --with-freetype-dir --with-zlib-dir --with-gd

確認freetype 2 在編譯中已被添加

make && make install

確認新產生的.so檔案是否跟php.ini中原來引入的路徑相同,如果不同需要修改php.ini 中的extension

安裝成功後重啟php-fpm

ps axu |grep php |grep -v 'grep'|awk '{print $2}'|xargs kill -9

/php5.5.38/sbin/php-fpm

重啟成功後查看phpinfo中的gd是否包含

FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.3.9

finished

相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!

推薦閱讀:

thinkPHP5架構實現分頁查詢步驟詳解

laravel使用Redis實現網站緩衝讀取實現步驟詳解

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.