如何在PHP中开启GD库支持

如何在PHP中开启GD库支持,第1张

开启GD库支持有以下几种方法 检测GD库是否安装命令 php5 -m | grep -i gd 或者 php -i | grep -i --color gd如未安装GD库,则为服务器安装,方法如下 如果是源码安装,则加入参数 --with-gd 如果是debian系的linux系统,用apt-get安装,如下 apt-get install php5-gd 如果是CentOS系的系统,用yum安装,如下 yum install php-gd 如果是suse系的linux系统,用yast安装,如下 yast -i php5_gd 如果嫌这个世界不够蛋疼呢,可以在原先编译PHP不支持GD的情况下附加 先下zlib源码,libpng源码,gd源码 解压后到源码目录 zlib目录 ./configure --prefix=/usr/local/zlib make make install make clean libpng目录 cp scripts/makefile.linux ./makefile ./configure --prefix=/usr/local/libpng make make install make clean gd目录 ./configure --prefix=/usr/local/libgd --with-png=/usr/local/libpng make make install make clean 最后在php.ini中,搜到[gd]后,在下面加一行 extension=/usr/local/libgdgd.so 然后重启php服务,如果不行,试试reboot 所以如果是源码安装,最好还是在编译PHP的时候加参数--with-gd Windows下开启PHP的GD库支持 找到php.ini,打开内容,找到: extension=php_gd2.dll 把最前面的分号“”去掉,再保存即可,如果本来就没有分号,那就是已经开启了。

标准的答案!和windows一样啊,打开php.ini,把gd相关的扩展打开,也就把extension=php_gd2.dll前面的分号去掉,再重启网络服务servicenetworkrestart

linux下为php添加GD库的步骤如下:

一、下载

gd-2.0.33.tar.gz http://www.boutell.com/gd/

jpegsrc.v6b.tar.gz http://www.ijg.org/

libpng-1.2.7.tar.tar http://sourceforge.net/projects/libpng/

zlib-1.2.2.tar.gz http://sourceforge.net/projects/zlib/

freetype-2.1.9.tar.gz http://sourceforge.net/projects/freetype/

php-4.3.9.tar.gz http://www.php.net

二、安装

1.安装zlib

tar zxvf zlib-1.2.2.tar.gz

cd zlib-1.2.2

./configure

make

make install

2.安装libpng

tar zxvf libpng-1.2.7.tar.tar

cd libpng-1.2.7

cd scripts/

mv makefile.linux ../makefile

cd ..

make

make install

注意,这里的makefile不是用./configure生成,而是直接从scripts/里拷一个

3.安装freetype

tar zxvf freetype-2.1.9.tar.gz

cd freetype-2.1.9

./configure

make

make install

4.安装Jpeg

tar zxvf jpegsrc.v6b.tar.gz

cd jpeg-6b/

./configure --enable-shared

make

make test

make install

注意,这里configure一定要带--enable-shared参数,不然,不会生成共享库

5.安装GD

tar zxvf gd-2.0.33.tar.gz

cd gd-2.0.33

./configure --with-png --with-freetype --with-jpeg

make install

6.重新编译PHP

tar zxvf php-4.3.9.tar.gz

cd php-4.3.9

./configure (以前的参数) --with-gd --enable-gd-native-ttf --with-zlib --with-png --with-jpeg --with-freetype --enable-sockets

make

make install

<?php

phpinfo()

?>

Ok.....


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8396958.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-16
下一篇2023-04-16

发表评论

登录后才能评论

评论列表(0条)

    保存