PHP添加GD庫支援的步驟詳解

來源:互聯網
上載者:User
  1. [root@jbxue ~]# rpm -qa | grep zlib
  2. zlib-1.2.1.2-1.2
  3. zlib-devel-1.2.1.2-1.2
  4. You have new mail in /var/spool/mail/root
複製代碼

不存在的話,請手動下載編譯:http://ishare.iask.sina.com.cn/f/15275772.html

  1. tar zxvf zlib-1.2.2.tar.gz
  2. cd zlib-1.2.2
  3. ./configure
  4. make
  5. make install
複製代碼

2,安裝libpng http://sourceforge.net/projects/libpng/

  1. tar zxvf libpng-1.4.2.tar.tar
  2. cd libpng-1.4.2
  3. ./configure
  4. make
  5. make install
複製代碼

3.安裝freetype http://sourceforge.net/projects/freetype/

  1. tar zxvf freetype-2.3.12.tar.gz

  2. cd freetype-2.3.12

  3. ./configure

  4. make
  5. make install

複製代碼

4,安裝Jpeg http://www.ijg.org/

  1. tar zxvf jpegsrc.v8b.tar.gz

  2. cd jpeg-8b/

  3. ./configure --enable-shared

  4. make
  5. make test
  6. make install
複製代碼

注意,這裡configure一定要帶--enable-shared參數,不然,不會產生共用庫。

5,安裝GD https://bitbucket.org/pierrejoye/gd-libgd/downloads

  1. tar zxvf gd-2.0.33.tar.gz

  2. cd gd-2.0.33
  3. ./configure --with-png --with-freetype --with-jpeg

  4. make

  5. make install

複製代碼

6,安裝PHP php-5.2.11.tar.gz

  1. tar zxvf php-5.2.11.tar.gz

  2. cd php-5.2.11
  3. ./configure選項見下方

  4. make

  5. make install

複製代碼

註:

  1. /usr/local/include/freetype2/freetype

  2. freetype

  3. /usr/local/include/include

  4. t1lig

  5. /usr/local/include/libpng14/

  6. png

  7. /usr/local/include

  8. jpeg

  9. [root@jbxue php-5.2.11]# ./configure --help | grep t1lib

  10. --with-t1lib[=DIR] GD: Include T1lib support. T1lib version >= 5.0.0 required
  11. [root@jbxue php-5.2.11]# ./configure --help | grep png
  12. --with-png-dir[=DIR] GD: Set the path to libpng install prefix
  13. [root@jbxue php-5.2.11]# ./configure --help | grep jpeg
  14. --with-jpeg-dir[=DIR] GD: Set the path to libjpeg install prefix
  15. [root@jbxue php-5.2.11]# ./configure --help | grep freetype
  16. --with-freetype-dir[=DIR] GD: Set the path to FreeType 2 install prefix
  17. [root@jbxue php-5.2.11]#

  18. ./configure --prefix=/opt/php5 --with-apxs2=/opt/apache/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/opt/php5/lib --with-gd --with-zlib --with-png-dir=/usr/local/include/libpng14/ --with-jpeg-dir=/usr/local/include --with-freetype-dir=/usr/local/include/freetype2/freetype (--with-t1lib --with-t1lib-dir=/usr/local/include/include)

複製代碼

最後只有T1Lib Support沒有啟用。

GD庫支援最終如下:

  1. Listen 81

  2. #
  3. # Dynamic Shared Object (DSO) Support
  4. #
  5. # To be able to use the functionality of a module which was built as a DSO you
  6. # have to place corresponding `LoadModule' lines at this location so the
  7. # directives contained in it are actually available _before_ they are used.
  8. # Statically compiled modules (those listed by `httpd -l') do not need
  9. # to be loaded here.
  10. #
  11. # Example:
  12. # LoadModule foo_module modules/mod_foo.so
  13. LoadModule php5_module modules/libphp5.so

  14. AddType application/x-httpd-php .php

  15. AddType application/x-httpd-php-source .phps
  16. #

複製代碼

在htdocs目錄中建立測試檔案info.php:

  1. [root@jbxue apache]# cat htdocs/info.php
  2. echo phpinfo();
  3. ?>
複製代碼

然後,在瀏覽器中訪問該檔案,可查詢GD庫支援的情況。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.