본문 바로가기

Linux Server 구축/1-2. Web Server

GD라이브러리 설치


GD라이브러리 설치 순서

1. zlib 설치
2. png 설치
3. jpeg 설치
4. freetype 설치
5. gd 설치

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

1. zlib 다운로드 (zlib-1.2.3.tar.gz) : http://www.zlib.net/

2. png 다운로드 (libpng-1.2.34.tar.gz) : http://www.libpng.org/pub/png/libpng.html

3. JPEG 다운로드 (jpegsrc.v6b.tar.gz) : http://quox.org/install/graphics/jpeg-6b.html

4. freetype 다운로드 (freetype-2.3.8.tar.gz) : http://freetype.sourceforge.net/index2.html

5. GD 다운로드 (gd-2.0.36RC1.tar.gz) : http://www.libgd.org/Main_Page

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

파일 압축 해제

 
[root@server3 GD-library]# pwd
/root/Desktop/GD-library

- 압축 해제 -
[root@server3 GD-library]# tar xvfz freetype-2.3.8.tar.gz
[root@server3 GD-library]# tar xvfz gd-2.0.36RC1.tar.gz
[root@server3 GD-library]# tar xvfz jpegsrc.v6b.tar.gz
[root@server3 GD-library]# tar xvfz libpng-1.2.34.tar.gz
[root@server3 GD-library]# tar xvfz zlib-1.2.3.tar.gz

- 폴더 이동 : 꼭 이동할 필요는 없지만 소스 설치시 구분하기 쉽게 하기 위해 이동해 준다. -
[root@server3 GD-library]# mv freetype-2.3.8 /usr/local/src
[root@server3 GD-library]# mv gd-2.0.36RC1 /usr/local/src
[root@server3 GD-library]# mv jpeg-6b/ /usr/local/src
[root@server3 GD-library]# mv libpng-1.2.34 /usr/local/src
[root@server3 GD-library]# mv zlib-1.2.3 /usr/local/src

- 설치 폴더 생성 : 꼭 만들어 줄 필요는 없지만 구분하기 쉽게 하기 위해 만들어준다. -
[root@server3 GD-library]# cd /usr/local
[root@server3 local]# pwd
/usr/local
[root@server3 local]# mkdir gd-lib




1. zlib 설치

 
[root@server3 src]# cd zlib-1.2.3/
[root@server3 zlib-1.2.3]# ./configure --help
usage:
  configure [--shared] [--prefix=PREFIX]  [--exec_prefix=EXPREFIX]
     [--libdir=LIBDIR] [--includedir=INCLUDEDIR]

[root@server3 zlib-1.2.3]# ./configure --shared --prefix=/usr/local/gd-lib/zlib-1.2.3
Checking for gcc...
Checking for shared library support...
Building shared library libz.so.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@server3 zlib-1.2.3]# make

- 중략

ln -s libz.so.1.2.3 libz.so
ln -s libz.so.1.2.3 libz.so.1
gcc -fPIC -O3 -DUSE_MMAP -o example example.o -L. libz.so.1.2.3
gcc -fPIC -O3 -DUSE_MMAP   -c -o minigzip.o minigzip.c
gcc -fPIC -O3 -DUSE_MMAP -o minigzip minigzip.o -L. libz.so.1.2.3

[root@server3 zlib-1.2.3]# make install

- 중략

cp zlib.3 /usr/local/gd-lib/zlib-1.2.3/share/man/man3
chmod 644 /usr/local/gd-lib/zlib-1.2.3/share/man/man3/zlib.3
[root@server3 zlib-1.2.3]#




2. png 설치

 
[root@server3 src]# cd libpng-1.2.34/
[root@server3 libpng-1.2.34]# ./configure --help
`configure' configures libpng 1.2.34 to adapt to many kinds of systems.

- 중략

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to <png-mng-implement@lists.sourceforge.net>.

[root@server3 libpng-1.2.34]# ./configure --prefix=/usr/local/gd-lib/libpng-1.2.34

- 중략

checking if assembler code in pnggccrd.c can be compiled without PNG_NO_MMX_CODE... yes
checking if libraries can be versioned... yes
checking for symbol prefix...
configure: pkgconfig directory is ${libdir}/pkgconfig
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libpng.pc
config.status: creating libpng-config
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands

[root@server3 libpng-1.2.34]# make

- 중략

cp libpng-config libpng12-config
cp libpng.pc libpng12.pc
make[1]: Leaving directory `/usr/local/src/libpng-1.2.34'

[root@server3 libpng-1.2.34]# make install

- 중략

make  install-data-hook
make[2]: Entering directory `/usr/local/src/libpng-1.2.34'
cd /usr/local/gd-lib/libpng-1.2.34/include; rm -f png.h pngconf.h
cd /usr/local/gd-lib/libpng-1.2.34/include; ln -s libpng12/png.h png.h
cd /usr/local/gd-lib/libpng-1.2.34/include; ln -s libpng12/pngconf.h pngconf.h
cd /usr/local/gd-lib/libpng-1.2.34/lib/pkgconfig; rm -f libpng.pc
cd /usr/local/gd-lib/libpng-1.2.34/lib/pkgconfig; ln -s libpng12.pc libpng.pc
make[2]: Leaving directory `/usr/local/src/libpng-1.2.34'
make[1]: Leaving directory `/usr/local/src/libpng-1.2.34'
[root@server3 libpng-1.2.34]#




3. jpeg 설치 - http://quox.org/install/graphics/jpeg-6b.html 참고

 
[root@server3 src]# cd jpeg-6b/
/usr/local/src/jpeg-6b
[root@server3 jpeg-6b]# ./configure --help

- 중략

Features and packages:
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --x-includes=DIR        X include files are in DIR
  --x-libraries=DIR       X library files are in DIR
--enable and --with options recognized:
  --enable-shared         build shared library using GNU libtool
  --enable-static         build static library using GNU libtool
  --enable-maxmem[=N]     enable use of temp files, set max mem usage to N MB

[root@server3 jpeg-6b]# ./configure --prefix=/usr/local/gd-lib/jpeg-6b/ --enable-shared --enable-static

- 중략

checking for objdir... .libs
creating libtool
checking libjpeg version number... 62
creating ./config.status
creating Makefile
creating jconfig.h
jconfig.h is unchanged

[root@server3 jpeg-6b]# make

- 중략

mv -f rdjpgcom.o rdjpgcom.lo
gcc -O2 -I. -c ./rdjpgcom.c >/dev/null 2>&1
./libtool --mode=link gcc  -o rdjpgcom rdjpgcom.lo
gcc -o rdjpgcom rdjpgcom.o
./libtool --mode=compile gcc -O2  -I. -c ./wrjpgcom.c
gcc -O2 -I. -c -fPIC -DPIC ./wrjpgcom.c
mv -f wrjpgcom.o wrjpgcom.lo
gcc -O2 -I. -c ./wrjpgcom.c >/dev/null 2>&1
./libtool --mode=link gcc  -o wrjpgcom wrjpgcom.lo
gcc -o wrjpgcom wrjpgcom.o

[root@server3 jpeg-6b]# strip rdjpgcom wrjpgcom .libs/{cjpeg,djpeg,jpegtran}

-------------------------------------------------------------------
- make 시 에러가 발생하면 아래와 같은 폴더를 생성해 준 다음 make clean 명령어를 해준 후 재 컴파일 해준다.
[root@server3 jpeg-6b]# pwd
/usr/local/gd-lib/jpeg-6b
[root@server3 jpeg-6b]# mkdir include
[root@server3 jpeg-6b]# mkdir bin
[root@server3 jpeg-6b]# mkdir lib
[root@server3 jpeg-6b]# mkdir man
[root@server3 jpeg-6b]# mkdir ./man/man1
-------------------------------------------------------------------

[root@server3 jpeg-6b]# pwd
/usr/local/src/jpeg-6b
[root@server3 jpeg-6b]# make install

- 중략

./libtool --mode=install /usr/bin/install -c cjpeg /usr/local/gd-lib/jpeg-6b//bin/cjpeg
/usr/bin/install -c .libs/cjpeg /usr/local/gd-lib/jpeg-6b//bin/cjpeg
./libtool --mode=install /usr/bin/install -c djpeg /usr/local/gd-lib/jpeg-6b//bin/djpeg
/usr/bin/install -c .libs/djpeg /usr/local/gd-lib/jpeg-6b//bin/djpeg
./libtool --mode=install /usr/bin/install -c jpegtran /usr/local/gd-lib/jpeg-6b//bin/jpegtran
/usr/bin/install -c .libs/jpegtran /usr/local/gd-lib/jpeg-6b//bin/jpegtran
./libtool --mode=install /usr/bin/install -c rdjpgcom /usr/local/gd-lib/jpeg-6b//bin/rdjpgcom
/usr/bin/install -c rdjpgcom /usr/local/gd-lib/jpeg-6b//bin/rdjpgcom
./libtool --mode=install /usr/bin/install -c wrjpgcom /usr/local/gd-lib/jpeg-6b//bin/wrjpgcom
/usr/bin/install -c wrjpgcom /usr/local/gd-lib/jpeg-6b//bin/wrjpgcom
/usr/bin/install -c -m 644 ./cjpeg.1 /usr/local/gd-lib/jpeg-6b//man/man1/cjpeg.1
/usr/bin/install -c -m 644 ./djpeg.1 /usr/local/gd-lib/jpeg-6b//man/man1/djpeg.1
/usr/bin/install -c -m 644 ./jpegtran.1 /usr/local/gd-lib/jpeg-6b//man/man1/jpegtran.1
/usr/bin/install -c -m 644 ./rdjpgcom.1 /usr/local/gd-lib/jpeg-6b//man/man1/rdjpgcom.1
/usr/bin/install -c -m 644 ./wrjpgcom.1 /usr/local/gd-lib/jpeg-6b//man/man1/wrjpgcom.1

[root@server3 jpeg-6b]# cp jversion.h /usr/local/gd-lib/jpeg-6b/include/ - 설치폴더의 include 폴더에 파일을 복사해준다.




4. freetype 설치

 
[root@server3 src]# cd freetype-2.3.8/
[root@server3 freetype-2.3.8]# pwd
/usr/local/src/freetype-2.3.8

[root@server3 freetype-2.3.8]# ./configure --prefix=/usr/local/gd-lib/freetype-2.3.8

FreeType build system -- automatic system detection

- 중략

configure: creating ./config.status
config.status: creating unix-cc.mk
config.status: creating unix-def.mk
config.status: creating freetype-config
config.status: creating freetype2.pc
config.status: creating ftconfig.h
config.status: executing libtool commands
make: `unix'를 위해 할 일이 없습니다

[root@server3 freetype-2.3.8]# make

- 중략

libtool: link: ranlib /usr/local/src/freetype-2.3.8/objs/.libs/libfreetype.a
libtool: link: ( cd "/usr/local/src/freetype-2.3.8/objs/.libs" && rm -f "libfreetype.la" && ln -s "../libfreetype.la" "libfreetype.la" )

[root@server3 freetype-2.3.8]# make install

- 중략

/usr/bin/install -c -m 644 ./builds/unix/ft2unix.h \
          /usr/local/include/ft2build.h
/usr/bin/install -c -m 644 ./builds/unix/ftconfig.h                        \
          /usr/local/include/freetype2/freetype/config/ftconfig.h
/usr/bin/install -c -m 644 /usr/local/src/freetype-2.3.8/objs/ftmodule.h                          \
          /usr/local/include/freetype2/freetype/config/ftmodule.h
/usr/bin/install -c -m 755 ./builds/unix/freetype-config \
          /usr/local/bin/freetype-config
/usr/bin/install -c -m 644 ./builds/unix/freetype2.m4 \
          /usr/local/share/aclocal/freetype2.m4
/usr/bin/install -c -m 644 ./builds/unix/freetype2.pc \
          /usr/local/lib/pkgconfig/freetype2.pc
[root@server3 freetype-2.3.8]#




5. gd 설치

 
[root@server3 src]# cd gd-2.0.36RC1/
[root@server3 gd-2.0.36RC1]# pwd
/usr/local/src/gd-2.0.36RC1

[root@server3 gd-2.0.36RC1]# ./configure --help
`configure' configures GD 2.0.36 to adapt to many kinds of systems.

- 중략

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to <http://bugs.libgd.org>.

[root@server3 gd-2.0.36RC1]# ./configure --prefix=/usr/local/gd-lib/gd-2.0.36RC1 --with-png=/usr/local/gd-lib/libpng-1.2.34 --with-jpeg=/usr/local/gd-lib/jpeg-6b/ --with-freetype=/usr/local/gd-lib/freetype-2.3.8

- 중략

** Configuration summary for gd 2.0.36: - 확인해준다.

   Support for PNG library:          yes
   Support for JPEG library:         yes
   Support for Freetype 2.x library: yes - 무료 폰트 렌더링 라이브러리
   Support for Fontconfig library:   no
   Support for Xpm library:          no - unix의 이미지 포맷 라이브러리
   Support for pthreads:             yes

configure: creating ./config.status
config.status: creating Makefile
config.status: creating config/Makefile
config.status: creating config/gdlib-config
config.status: creating test/Makefile
config.status: creating config.h
config.status: executing depfiles commands

[root@server3 gd-2.0.36RC1]# make

- 중략

make[2]: Leaving directory `/usr/local/src/gd-2.0.36RC1'
make[1]: Leaving directory `/usr/local/src/gd-2.0.36RC1'

[root@server3 gd-2.0.36RC1]# make install

- 중략

make[2]: Leaving directory `/usr/local/src/gd-2.0.36RC1'
make[1]: Leaving directory `/usr/local/src/gd-2.0.36RC1'
[root@server3 gd-2.0.36RC1]#




6. php 재컴파일

 
[root@server3 src]# cd php-5.2.8
[root@server3 php-5.2.8]# pwd
/usr/local/src/php-5.2.8

[root@server3 php-5.2.8]# make clean - 이전 컴파일 정보 삭제
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp5.la sapi/cli/php libphp5.la modules/* libs/*

[root@server3 php-5.2.8]# ./configure
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-config-file-path=/usr/local/apache/conf \
--with-exec-dir=/usr/local/apache/bin \
--enable-mbstring --with-mcrypt=/usr/local/libmcrypt \
--with-gd=/usr/local/gd-lib/gd-2.0.36RC1 \
--with-jpeg-dir=/usr/local/gd-lib/jpeg-6b \
--with-freetype-dir=/usr/local/gd-lib/freetype-2.3.8 \
--with-png-dir=/usr/local/gd-lib/libpng-1.2.34 \
--with-zlib-dir=/usr/local/gd-lib/zlib-1.2.3
- 녹색 부분만 재컴파일시 추가해준다.

+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

[root@server3 php-5.2.8]# make && make install or make -> make test -> make install 로 하면 좀더 정확하게 확인하며 설치할 수 있다.