PHP & Others

php설치 -gd,gif,mcrypt,mhash,pdf,swf 연동하기

페이지 정보

본문

php설치 -gd,gif,mcrypt,mhash,pdf,swf 연동하기

 글쓴이 : 오렌지블루

 저작권자 이메일 : unbinara@dreamwiz.com

 출처 : www.phpschool.com

 작성일 : 2002/04/26 14:03:25

 글내용 

이 글은 초보자용임을 밝혀두며, 몇몇은 아래 팁에서 참조한것도 있다
따라서, 돌던지시기전에 초보를 위해 이젠 php옵션과 설치 패키지 포함시키는 법등에서 더 이상 헤메이지 말기로 하자.

예전에도 한번 글을 올렸는뎅...

필자는 php프로그래밍을 하는 직원이 계속 이것 때문에 헤메이길래
한번 시도해보았다. 가치가 있는지 없는지는 둘째치고 프로그래밍하기도
바쁜데 설치땜에 시간낭비하지 않기를 바라면서 쓴다

우선, rpm이 깔려있을때는 gd패키지만 지우고 gd(gif패치)소스를 받아 설치하면 된다. 가장 쉬운방법이다.

그리고, zlib를 지우면서 발생하는 삽질을 더이상하지말고 아래를 흩어보기바란다.


[apm설치중 gd,gif,png,pdf,ming,swf,mcrypt,mhash,openssl등]

참조 패키지
※소스
http://sourceforge.net/project/showfiles.php?group_id=976 : curl-7.9.5.tar.gz
http://www.php.net/extra/ : number4.tar.gz
http://www.engelschall.com/sw/mm/
http://mhash.sourceforge.net/dl/ : mhash-0.8.13.tar.gz
ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/ : libmcrypt-2.5.0.tar.gz
http://www.rime.com.au/gd : gd-2.0.1gif.tar.gz
ftp://ftp.sgi.com/sgi/graphics/grafica/flash : dist.99.linux.tar.Z
http://www.opaque.net/ming/ : ming-0.2a.tgz
http://www.fastio.com : pdflib-4.0.2.tar.gz (http://www.fastio.com/README202.txt)
http://www.pdflib.com : clibpdf202r1.tar.gz
http://www.gzip.org/zlib/ : zlib-1.1.4.tar
http://www.libpng.org/pub/png/libpng.html : libpng-1.2.1.tar.gz
ftp://ftp.uu.net/graphics/jpeg/ : jpegsrc.v6b.tar.gz
http://freetype.sourceforge.net/download.html#mirrors : freetype-2.0.9.tar.gz(ftp://gd.tuwien.ac.at/publishing/freetype/freetype2/)
http://www.libtiff.org/ : tiff-v3.5.7.tar.gz
ftp://sunsite.unc.edu/pub/Linux/libs/graphics/ : t1lib-1.3.1.tar.gz


※rpm zlib 보안업
http://www.redhat.com/support/errata/RHSA-2002-026.html
ftp://updates.redhat.com/7.2/en/os/SRPMS/zlib-1.1.3-25.7.src.rpm
아래 1번식으로 할 경우 ZLIB1.1.3이 보안버그가 있다 따라서 위의 패키지를 받아 재패키징하여 업하자

###############################################################################
1. RPM이 존재할 경우 RPM을 이용하여 GD(GIF패치된)만을 컴파일 하여 사용한다. 손쉬운 방법이다

※여기서는 gif지원을 위해 gd rpm을 지운후 gdgif패치를 사용할 것이다

(1) curl 설치
shell>tar -xvzf curl-7.9.5.tar.gz
shell>cd curl-7.9.5
shell>./configure
shell>make
shell>make install

※curl 라이브러리는 /usr/local/lib
나머지 헤더는/usr/local/include/curl 로 들어간다

(2) MHash
shell>tar -xvzf mhash-0.8.13.tar.gz
shell>cd mhash-0.8.13
shell>./configure
shell>make
shell>make install

(3) libMCrypt
shell>tar -xvzf libmcrypt-2.5.0.tar.gz
shell>cd libmcrypt-2.5.0
shell>./configure
shell>make
shell>make install

shell>vi /etc/ld.so.conf
/usr/local/lib 추가

shell>ldconfig

※ 누군가는 mcrypt rpm패키지로 깐다고 했는데 그러지 말자.
php에서 이용하는것은 libmcrypt이다

(4) PDFLIB
shell>tar -xvzf pdflib-4.0.2.tar.gz
shell>cd pdflib-4.0.2
shell>./configure
shell>make
shell>make install

shell>vi /etc/ld.so.conf
/usr/lib/tcl8.3/pdflib 추가

shell>ldconfig


(5) ming
shell>tar -xvzf ming-0.2a.tgz
shell>cd ming-0.2a
shell>make
shell>make install

※ming은 /usr/lib 에 들어간다

(6) clibpdf
shell>tar -xvzf clibpdf202r1.tar.gz
shell>cd ClibPDF
shell>cd source
shell>mv Makefile Makefile.orig
shell>cp Makefile.Linux Makefile
shell>make lib
shell>make install
shell>make test

shell>vi /etc/ld.so.conf
/usr/local/lib 추가

shell>ldconfig


(7) swf
shell>tar -xvzf dist.99.linux.tar.Z
shell>mv dist swfdist
shell>mkdir swf
shell>cd swfdist
shell>mkdir /usr/local/swf/include
shell>mkdir /usr/local/swf/lib
shell>mkdir /usr/local/swf/fonts
shell>mkdir /usr/local/swf/psfonts
shell>mkdir /usr/local/swf/bin
shell>cp swf.h /usr/local/swf/include
shell>cp libswf.a /usr/local/swf/lib
shell>cp bin/* /usr/local/swf/bin
shell>cp fonts/* /usr/local/swf/fonts
shell>cp psfonts/* /usr/local/swf/psfonts


(8) gd(gif지원)
shell>tar -xvzf gd-2.0.1gif.tar.gz
shell>mv gd-2.0.1 gd201
shell>cd gd201

shell>vi Makefile
INCLUDEDIRS=-I. -I/usr/include/freetype2 -I/usr/local/include
LIBDIRS=-L/usr/local/lib -L/usr/lib

※ 위의 부분에서 X관련설정은 모두 빼고 위와 같이 고쳤다.
왜냐하면 필자는 X를 설치하지 않았기 때문이다

shell>make install

(9) mm라이브러리
shell>tar -xvzf mm-1.1.3.tar.gz
shell>cd mm-1.1.3
shell>./configure --disable-shared
shell>make
shell>make install
shell>cd ..

※환경변수 LD_LIBRARY_PATH 에 추가시킨다.
shell>vi /etc/profile

#mm-1.1.3
export LD_LIBRARY_PATH=/usr/local/mm-1.1.3:$LD_LIBRARY_PATH

※위의사항을 맨밑에 추가한다

shell>source /etc/profile

(10) apache
shell>tar -xvzf apache_1.3.24.tar.gz
shell>cd apache_1.3.24

shell>./configure --prefix=/usr/local/apache1324



(11) number와 php설치
shell>tar xvfz php-4.1.2.tar.gz
shell>cp number4.tar.gz php-4.1.2/ext
shell>cd php-4.1.2/ext
shell>tar -xvfz number4.tar.gz

shell>cd ..

shell>vi do-conf
shell>chmod 755 do-conf
shell>./do-conf

make
make install

※ 자 이제 do-conf에 쓰일 환경설정을 보자
./configure
--with-apache=/usr/local/apache_1.3.24
--with-config-file-path=/usr/local/apache1324/conf
--with-mysql=/usr/local/mysql32349
--with-pgsql=/usr/local/pgsql72
--with-jpeg-dir=/usr/lib
--with-png-dir=/usr/lib
--with-gif-dir=/usr/lib
--with-zlib-dir=/usr/lib
--with-gd=/usr/local/gd201
--with-freetype-dir=/usr/include/freetype2
--with-zlib=/usr
--with-ming=/usr/lib
--with-tiff-dir=/usr/lib
--with-pdflib=/usr/local/pdflib-4.0.2
--with-cpdflib
--with-openssl
--with-gettext
--with-kerberos
--with-swf=/usr/local/swf
--with-mm
--with-mhash=/usr/local/lib
--with-mcrypt=/usr/local/lib
--with-mod_charset
--with-regex=php
--with-curl
--with-ldap
--enable-gd-native-ttf
--enable-ftp
--enable-sockets
--disable-debug
--enable-sysvsem=yes
--enable-sysvshm=yes
--enable-shmop
--enable-freetype-4bit-antialias-hack
--enable-calendar
--enable-sigchild
--enable-magic-quotes
--enable-trans-sid
--enable-inline-optimization
--enable-bcmath

옵션이 무진장 많다.
우선 /usr/lib라고 지정된 것은 RPM으로 깐 것은
/usr/lib속으로 라이브러리가 들어가기 때문이다
우리가 tar.gz으로 설치한 것은 /usr/local/lib속으로 들어간다

유일하게 ming소스만이 /usr/lib로 들어간다

자이제 php를 설치했으면 나머지 아시는 대로 아파치를 설치해서
phpinfo()함수를 써서 보자

정말 많은 것을 지원하게끔 했다..^^

※주의사항
이렇게 많은 옵션을 줄 필요가 없다
꼭 필요한 것만 패키지를 설치하자
이렇게 설치했다면 아파치프로세스당 메모리가 5.0% 이상을 넘어간다
보통 간략히 필요한 것만 설치했을 경우는 약 2% 내외이다

아무튼 필요한 것만 설치하는 것이 좋은 것이다

#######################################################################################

2. 이제 관련 RPM을 모두 지우고 소스로만 간다.
특히 소스로 가는경우 위에서 언급했듯이 ZLIB가 보안버그가 있어 현재 소스로 1.1.4버젼이 나온상태이다

※여기서 핵심사항이 하나 있다.
zlib를 rpm -e zlib하면 엄청 의존성 에러가 난다.
그만큼 이것을 참조하는 패키지가 많다는 것이다. 특히 zlib를 잘못하면 mysqlclient 및 심지어 rpm명령도 에러가 나버린다
그만큼 조심해야 한다. 한번 rpm -e zlib를 해보고 어떤 패키지와 관련있는지 주의하자

소스로 설치한후 다시 위의 패키지를 사용하면 문제없이 사용되는 것을 확인했다.물론, 내가아는 패키지만 실험해보았다



(1) RPM을 지운다
rpm -e --nodeps zlib-1.1.3-25.7
rpm -e --nodeps zlib-devel-1.1.3-25.7
rpm -e --nodeps freetype-2.0.3-7
rpm -e --nodeps freetype-devel-2.0.3-7
rpm -e --nodeps freetype-utils-2.0.3-7
rpm -e --nodeps gd-1.8.4-4
rpm -e --nodeps gd-devel-1.8.4-4
rpm -e --nodeps libjpeg-6b-16
rpm -e --nodeps libjpeg-devel-6b-16
rpm -e --nodeps libjpeg6a-6a-8
rpm -e --nodeps libpng-1.0.12-2
rpm -e --nodeps libpng-devel-1.0.12-2
rpm -e --nodeps libtiff-3.5.5-13
rpm -e --nodeps libtiff-devel-3.5.5-13
rpm -e --nodeps libungif-4.1.0-9
rpm -e --nodeps libungif-devel-4.1.0-9
rpm -e --nodeps libungif-progs-4.1.0-9

(2) 제일먼저 zlib부터 설치한다
※ 디렉토리를 zlib로 바꾸어준다. 중요하다. 안그러면 에러가 생길가능성이 농후하다
왜냐고 묻지를 마라.
shell>tar -xvzf zlib-1.1.4.tar.gz
shell>mv zlib-1.1.4 zlib
shell>cd zlib

//-->libz.so와 관련된 모듈을 생성시킨다 이것이 정말 중요하다

shell>./configure -s
shell>make

//--> libz.a를 만든다

shell>./configure
shell>make test
shell>make install

shell>cp libz.so* /usr/local/lib

shell>cd /usr/local/lib
shell>rm -rf libz.so
shell>rm -rf libz.so.1
shell>ln -s libz.so.1.1.4 libz.so
shell>ln -s libz.so.1.1.4 libz.so.1

//--> 기존 lib(rpm설치시)는 /usr/lib이므로

shell>vi /etc/ld.so.conf
/usr/local/lib추가

shell>ldconfig 적용명령





(3) 위의 (1)번부터 (7)번까지 동일하게 설치하고 (9)번을 설치한다




(4) libpng설치
shell>tar -xvzf libpng-1.2.1.tar.gz
shell>mv libpng-1.2.1 libpng121
shell>cd libpng121
shell>cp scripts/makefile.linux ./makefile
shell>make test
shell>make install


(5) freetype설치
shell>tar -xvzf freetype-2.0.9.tar.gz
shell>mv freetype-2.0.9 freetype209
shell>cd freetype209
shell>./configure
shell>make
shell>make install

shell>ls /usr/local/include/freetype2 확인


(6) jepg 설치
shell>tar -xvzf jpegsrc.v6b.tar.gz
shell>mv jpeg-6b jpeg6b
shell>cd jpeg6b
shell>./configure --enable-shared --enable-static
shell>make
shell>make test
shell>make install


(7) libungif설치
shell>tar -xvzf libungif-4.1.0.tar.gz
shell>cd libungif-4.1.0
shell>./configure
shell>make
shell>make install


(8) libtiff
shell>tar -xvzf tiff-v3.5.7.tar.gz
shell>cd tiff-v3.5.7
shell>./configure

...중간에 설치하다 물어보면
yes한다
...

shell>make
shell>make install


(9) t1lib
shell>tar -xvzf t1lib-1.3.1.tar.gz
shell>./configure
--------------------------------------------------------------------------------------
onfigure finished!
Do: 'make' to compile the t1lib-package.
Do: 'make without_doc' to compile if you do not have LaTeX.
Do: 'make install' to install the t1lib-package.
---------------------------------------------------------------------------------------
※여기서 나는 latex가 없기때문에 make 를 하지않고 make without_doc를 했다

shell>make without_doc
shell>make install

(10) GD설치
shell>tar -xvzf gd-2.0.1gif.tar.gz
shell>mv gd-2.0.1 gd201
shell>cd gd201

//-->소스로 설치하기 때문에 일일이 include경로를 설치 디렉토리에 맞추어 변경해야한다
shell>vi gd.c
#include "/usr/local/zlib/zlib.h"

shell>vi gd_jpeg.c
#include "/usr/local/jpeg6b/jpeglib.h"
#include "/usr/local/jpeg6b/jerror.h"

shell>vi gd_png.c
#include "/usr/local/libpng121/png.h" /* includes zlib.h and setjmp.h */


shell>vi Makefile
INCLUDEDIRS=-I. -I/usr/local/include/freetype2 -I/usr/local/include
LIBDIRS=-L/usr/local/lib -L/usr/lib
INSTALL_LIB=/usr/local/lib
INSTALL_INCLUDE=/usr/local/include

shell>make
shell>make install

※여기서 관련 c소스를 수정하는 이유는 zlib관련해서 헤더위치가 틀리기 때문이다


자 긴시간이 끝났다

위의 아파치와 php설치를 참조하기로 하고 여기서는 설정파일만보자

./configure
--with-apache=/usr/local/apache_1.3.24
--with-config-file-path=/usr/local/apache1324/conf
--with-mysql=/usr/local/mysql32349
--with-pgsql=/usr/local/pgsql72
--with-jpeg-dir=/usr/local/lib
--with-png-dir=/usr/local/lib
--with-gif-dir=/usr/local/lib
--with-zlib-dir=/usr/local/lib
--with-gd=/usr/local/gd201
--with-freetype-dir=/usr/local/include/freetype2
--with-zlib
--with-ming=/usr/lib
--with-tiff-dir=/usr/local/lib
--with-pdflib=/usr/local/pdflib-4.0.2
--with-cpdflib
--with-openssl
--with-gettext
--with-kerberos
--with-swf=/usr/local/swf
--with-mm
--with-mhash=/usr/local/lib
--with-mcrypt=/usr/local/lib
--with-mod_charset
--with-regex=php
--with-curl
--with-ldap
--enable-gd-native-ttf
--enable-ftp
--enable-sockets
--disable-debug
--enable-sysvsem=yes
--enable-sysvshm=yes
--enable-shmop
--enable-freetype-4bit-antialias-hack
--enable-calendar
--enable-sigchild
--enable-magic-quotes
--enable-trans-sid
--enable-inline-optimization
--enable-bcmath

※센스가 있는 사람은 이제 뭔가를 눈치챘을 것이다
소스로 설치했기때문에 라이브러리 위치가 ming을 제외하고 /usr/lib에서 /usr/local/lib로 바뀌었다.
또하나 다른점은 freetype위치가 변경되었다
마지막으로 하나 zlib 이다.
rpm시에는 --with-zlib=/usr 하면 잡혔는데 소스로 설치했을 경우
/usr 혹은 /usr/local/lib하면 다 않잡힌다
반드시 이렇게 해야만 잡힌다. 왜냐고 묻지마라. 필자도 괴롭다..
#######################################################################################

마지막으로 /etc/ld.so.conf를 들여다 보자
필자의 것인데 이것만큼은 꼭들어있어야 한다
모두 설치후 확인하자

shell>vi /etc/ld.so.conf

/usr/kerberos/lib
/usr/local/lib/libmcrypt
/usr/lib
/usr/lib/tcl8.3/pdflib
/usr/local/lib
/usr/local/pgsql72/lib

위와 같은데 자신이 설치한 것과 해당사항이 있으면 꼭 집어넣어주자.
위에서 거의 같이 했다면 상관없을 것이다.

[수정사항]
--with-t1lib=/usr/local/t1lib-1.3.1
이것이 빠졌음다..--;


수정하면서 그냥 넣을까 하다가, 이전에 보신분이 헤멜까봐서 뒤에넣습니다

그리고, 위에 사항이 완벽히 맞는다는 보장은 없습니다.
제 설치 환경에 대해서 또 빠트렸네요..--;

레드헷 리눅스 7.2이고 커널 2.4.18이며, php4.1.2임니다.

따라서, php버젼에따라서 옵션이 변동이 있을수도 있으니 참조하시기 바랍니다

관련자료

등록된 댓글이 없습니다.
Today's proverb
일은 모든 것을 정복한다. (호메로스)