php安装gd(freetype、jpeg、png、zlib)

安装php需要gd(freetype、jpeg、png)支持

1、安装freetype

[root@localhost softs]# tar xf freetype-2.5.0.tar.bz2 -C /usr/src/

[root@localhost softs]# cd /usr/src/freetype-2.5.0

[root@localhost freetype-2.5.0]# ./configure --prefix=/usr/local/freetype --enable-shared

[root@localhost freetype-2.5.0]#  make && make install


2、安装png

[root@localhost softs]# tar xf libpng-1.6.6.tar.gz -C /usr/src/

[root@localhost softs]# cd /usr/src/libpng-1.6.6/

[root@localhost libpng-1.6.6]# ./configure --prefix=/usr/local/png --enable-shared

[root@localhost libpng-1.6.6]# make  && make  install 


3、安装jpeg

[root@localhost softs]# tar xf jpeg-6b.tar.gz -C /usr/src/

[root@localhost softs]# cd /usr/src/jpeg-9/

[root@localhost jpeg-9]# ./configure --prefix=/usr/local/jpeg --enable-shared

[root@localhost jpeg-9]# make  && make install


4、安装zlib

[root@localhost softs]# tar xf zlib-1.2.2.2.tar.gz -C /usr/src/

[root@localhost softs]# cd /usr/src/zlib-1.2.2.2

[root@localhost zlib-1.2.2.2]# ./configure --prefix=/usr/local/zlib

[root@localhost zlib-1.2.2.2]#  make && make install 


5、安装libgd

[root@localhost softs]# tar xf libgd-2.1.0.tar.xz -C /usr/src/

[root@localhost softs]# cd /usr/src/libgd-2.1.0/

[root@localhost libgd-2.1.0]# ./configure --prefix=/usr/local/gd --enable-shared --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-png=/usr/local/png --with-zlib=/usr/local/zlib


编译 gd-2.0.33.tar.gz 时出现了如下错误:

/usr/bin/ld: /usr/local/lib/libz.a(compress.o): relocation R_X86_64_32 against `a local symbol' can not be used when

making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libgd.la] 错误 1
make[2]: Leaving directory `/usr/local/src/gd-2.0.33'
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory `/usr/local/src/gd-2.0.33'
make: *** [all] 错误 2

解决办法 : 重新安装 zlib-1.2.3.tar.gz

[root@unix-server1 zlib-1.2.3]#sudo  CFLAGS="-O3 -fPIC" ./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@unix-server1 zlib-1.2.3]# make
gcc -O3 -fPIC -DUSE_MMAP   -c -o example.o example.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o adler32.o adler32.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o compress.o compress.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o crc32.o crc32.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o gzio.o gzio.c 
gcc -O3 -fPIC -DUSE_MMAP   -c -o uncompr.o uncompr.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o deflate.o deflate.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o trees.o trees.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o zutil.o zutil.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o inflate.o inflate.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o infback.o infback.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o inftrees.o inftrees.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o inffast.o inffast.c
ar rc libz.a adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o
gcc -O3 -fPIC -DUSE_MMAP -o example example.o -L. libz.a
gcc -O3 -fPIC -DUSE_MMAP   -c -o minigzip.o minigzip.c
gcc -O3 -fPIC -DUSE_MMAP -o minigzip minigzip.o -L. libz.a


[root@unix-server1 zlib-1.2.3]# make install
cp zlib.h zconf.h /usr/local/zlib//include
chmod 644 /usr/local/zlib//include/zlib.h /usr/local/zlib//include/zconf.h
cp libz.a /usr/local/zlib//lib
cd /usr/local/zlib//lib; chmod 755 libz.a
cd /usr/local/zlib//lib; if test -f libz.so.1.2.3; then \
          rm -f libz.so libz.so.1; \
          ln -s libz.so.1.2.3 libz.so; \
          ln -s libz.so.1.2.3 libz.so.1; \
          (ldconfig || true)  >/dev/null 2>&1; \
        fi
cp zlib.3 /usr/local/zlib//share/man/man3
chmod 644 /usr/local/zlib//share/man/man3/zlib.3
[root@unix-server1 zlib-1.2.3]# make clean
rm -f *.o *~ example minigzip \
           libz.* foo.gz so_locations \
           _match.s maketree contrib/infback9/*.o


[root@localhost libgd-2.1.0]# ./configure --prefix=/usr/local/gd --enable-shared --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-png=/usr/local/png --with-zlib=/usr/local/zlib

[root@localhost libgd-2.1.0]# make && make install


6、重新配置文件

[root@localhost libgd-2.1.0]# echo "/usr/local/mysql/lib" >> /etc/ld.so.conf

[root@localhost libgd-2.1.0]# ldconfig 



7、安装 php

[root@localhost softs]# tar xf php-5.3.27.tar.gz -C /usr/src/

[root@localhost softs]# cd /usr/src/php-5.3.27/

[root@localhost php-5.3.27]# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --disable-ipv6 --with-libxml-dir=/usr --with-openssl=/usr --with-zlib=/usr --with-bz2=/usr --with-curl=/usr  --enable-ftp --with-mysql=/usr/local/mysql --with-mysql-sock=/var/run/mysqld/mysql5.socket  --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-bcmath --enable-mbstring --enable-sockets --with-gd --with-jpeg-dir=/usr/local/jpeg/ --with-png-dir=/usr/local/png/ --with-freetype-dir=/usr/local/freetype --with-zlib-dir=/usr/local/zlib/ --with-zlib

[root@localhost php-5.3.27]# make && make install

8、查看php的所有支持模块

[root@localhost lib]# php -m
[PHP Modules]
bcmath
bz2
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
ldap
libxml
mbstring
mysql
mysqli
openssl
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
sockets
SPL
SQLite
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib


[Zend Modules]

php安装gd(freetype、jpeg、png、zlib)_第1张图片


你可能感兴趣的:(with,-fpic,recompile,zlib安装)