php添加gd

一 GD简介:

    php处理图形的扩展库,提供了一系列用来处理图片的API。如果开发过程中发现有页面验证码不能显示,则要考虑检查phpinfo(),是否支持GD库。

二 思路:

网上发现添加GD库的方法,到处是单独下载libgd源码方法,为编译libgd,还需要下载一系列的依赖,相当麻烦。以前玩WAMP,记得gd.dll都是php自带的。猜想,在linux下,通过php源码或许能得到相应的.so文件。果不其然,在php_src/ext下还真有gd的源码。

三 版本:php 5.6.9

四 过程:

1:编译生成.so文件

[root@host gd]# pwd                                #路径

/opt/php/php-5.6.9/ext/gd

[root@host gd]# ../../scripts/phpize               #用phpize工具生成configure文件

Configuring for:

PHP Api Version:         20121113

Zend Module Api No:      20121212

Zend Extension Api No:   220121212

[root@host gd]#

[root@host gd]# ./configure

>  --prefix=$HOME/install/php/  

>  --with-php-config= $(php安装路径)/bin/php-config

[root@host gd]# make install

...                                                                 #省略其他打印

cp ./.libs/gd.so /opt/php/php-5.6.9/ext/gd/modules/gd.so  #目标文件生成

cp ./.libs/gd.lai /opt/php/php-5.6.9/ext/gd/modules/gd.la

PATH="$PATH:/sbin" ldconfig -n /home/lzc/LAMP/php/php-5.6.9/ext/gd/modules

----------------------------------------------------------------------

Libraries have been installed in:

   /home/lzc/LAMP/php/php-5.6.9/ext/gd/modules

....                                                               #省略其他打印

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20131212/

Installing header files:          /usr/local/include/php/

 

[root@host gd]# cp /usr/local/lib/php/extensions/no-debug-non-zts-20121312/gd.so /opt/php/ lib/php/extensions/no-debug-non-zts-20121312/gd.so                                                    #将文件copy到自己的php安装路径下

 

2:编辑php.ini,加入扩展

    extension=/opt/php/lib/php/extensions/no-debug-non-zts-20131212/gd.so

原文地址:https://www.cnblogs.com/bethal/p/5617836.html