为PHP配置GD库

2022-07-01 16:02:36 浏览数 (1)

安装zlib

root@localhost:~# tar zxvf zlib-1.2.3.tar.gz

root@localhost:~# cd zlib-1.2.3/

root@localhost:~/zlib-1.2.3# 

root@localhost:~/zlib-1.2.3# ./configure --prefix=/usr/local/zlib

Checking for gcc...

Building static library libz.a version 1.2.3 with gcc.

Checking for unistd.h... Yes.

Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()

Checking for vsnprintf() in stdio.h... Yes.

Checking for return value of vsnprintf()... Yes.

Checking for errno.h... Yes.

Checking for mmap support... Yes.

root@localhost:~/zlib-1.2.3# make

root@localhost:~/zlib-1.2.3# make install

安装libpng

root@localhost:~# tar jxvf libpng-1.2.8.tar.bz2

root@localhost:~/libpng-1.2.8# mv ./scripts/makefile.linux ./makefile

root@localhost:~/libpng-1.2.8# make

root@localhost:~/libpng-1.2.8# make install

安装freetype

root@localhost:~# tar zxvf freetype-2.1.10.tar.gz 

root@localhost:~# cd freetype-2.1.10/

root@localhost:~/freetype-2.1.10# ./configure --prefix=/usr/local/freetype

root@localhost:~/freetype-2.1.10# make

root@localhost:~/freetype-2.1.10# make install

安装Jpeg

root@localhost:~# tar zxvf jpegsrc.v6b.tar.gz

root@localhost:~# cd jpeg-6b/

root@localhost:~/jpeg-6b# ./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static --enable-shared参数用来设置生成共享库 

root@localhost:~/jpeg-6b# make 

./libtool --mode=compile gcc -O2  -I. -c ./jcapimin.c

make: ./libtool: Command not found

make: *** [jcapimin.lo] Error 127

root@localhost:/etc/apt# ls

apt.conf.d    sources.list~      sources.list.d  trusted.gpg~

preferences.d  sources.listbak    trustdb.gpg    trusted.gpg.d

sources.list  sources.list_bak2  trusted.gpg

root@localhost:/etc/apt# cp sources.list_bak2 sources.list

sources.list_bak2为我自己创建的本地源列表

root@localhost:/etc/apt# cat sources.list_bak2 

deb file:///media/cdrom precise main

root@localhost:/etc/apt# apt-get update

root@localhost:/etc/apt# apt-get install libtool

Reading package lists... Done

Building dependency tree       

Reading state information... Done

The following extra packages will be installed:

  autotools-dev libltdl-dev

Suggested packages:

  libtool-doc autoconf automaken gfortran fortran95-compiler gcj

The following NEW packages will be installed:

  autotools-dev libltdl-dev libtool

0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.

Need to get 0 B/547 kB of archives.

After this operation, 2,561 kB of additional disk space will be used.

Do you want to continue [Y/n]? Y

root@localhost:~# cd jpeg-6b/

root@localhost:~/jpeg-6b# make clean

rm -f *.o *.lo libjpeg.a libjpeg.la

rm -f cjpeg djpeg jpegtran rdjpgcom wrjpgcom

rm -f ansi2knr core testout* config.log config.status

rm -f -r knr .libs _libs

root@localhost:~/jpeg-6b# cp /usr/share/libtool/config/config.sub .

root@localhost:~/jpeg-6b# cp /usr/share/libtool/config/config.guess .

root@localhost:~/jpeg-6b# ./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static 该版本有待更正 无法自动创建安装目录,自己创建一下:

mkdir -p /usr/local/jpeg/include  mkdir -p /usr/local/jpeg/lib  mkdir -p /usr/local/jpeg/bin  mkdir -p /usr/local/jpeg/man/man1

编译安装

root@localhost:~/jpeg-6b# make 

root@localhost:~/jpeg-6b# make install

安装GD

root@localhost:~# tar zxvf gd-2.0.33.tar.gz

root@localhost:~# cd gd-2.0.33/

root@localhost:~/gd-2.0.33# ./configure --with-png --with-jpeg --with-freetype=/usr/local/freetype root@localhost:~/gd-2.0.33# make

root@localhost:~/gd-2.0.33# make install

安装php

注:如若已经安装过php 删除安装目录即可:

root@localhost:~# rm -rf /usr/local/php5

root@localhost:~# tar zxvf php-5.4.4.tar.gz 

root@localhost:~# cd php-5.4.4/

root@localhost:~/php-5.4.4# ./configure --prefix=/usr/local/php5/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql5/ --enable-mbstring --with-gd --enable-gd-native-ttf --with-zlib-dir=/usr/local/zlib --with-freetype-dir=/usr/local/freetype root@localhost:~/php-5.4.4# make 

root@localhost:~/php-5.4.4# make install

root@localhost:~# /usr/local/apache2/bin/apachectl stop

root@localhost:~# /usr/local/apache2/bin/apachectl start

测试

[root@orcl10g ~]# cd /usr/local/apache2/htdocs/

输入指针函数显示php信息

[root@orcl10g htdocs]# vi index.php

写入内容如下

<?

phpinfo();

?>

浏览器查看有无gd参数

0 人点赞