欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP添加GD库支持的步骤详解

程序员文章站 2022-06-10 09:57:46
...
  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库支持的情况。