[{TableOfContents}]

!!!참고 사이트
*[http://www.php.net/manual/kr/install.apache2.php]
*[http://naggingmachine.blogspot.com/2006/08/php5.html]
*[http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=qna_install&wr_id=2387&sfl=&stx=&sst=wr_hit&sod=desc&sop=and&page=1]

!!!mcrypt 설치
{{{
wget http://jaist.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz
tar -xvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
cd ..
}}}

!!!gzip설치
{{{
wget ftp://mirrors.kernel.org/gnu/gzip/gzip-1.2.4.tar
tar -xvf gzip-1.2.4.tar
cd gzip-1.2.4
./configure
make && make install
cd ..
}}}

!!!libxml설치
{{{
wget ftp://xmlsoft.org/libxml2/libxml2-2.6.30.tar.gz
tar -xvzf libxml2-2.6.30.tar.gz
cd libxml2-2.6.30 
./configure
make && make install
cd ..
}}}

!!!Zlib 설치
{{{
wget http://www.zlib.net/zlib-1.2.3.tar.gz
tar -xvzf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure 
make && make install 
cd ..
}}}

!!!LibPng 설치 
{{{
wget http://nchc.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.29.tar.gz
tar -xvzf libpng-1.2.29.tar.gz
cd libpng-1.2.29
cp scripts/makefile.linux makefile
make test
make install 
cd ..
}}}

!!!GD설치
{{{
wget http://www.libgd.org/releases/oldreleases/gd-2.0.34.tar.gz
tar -xvzf gd-2.0.34.tar.gz
cd gd-2.0.34
./configure
make all 
cd ..

참고 : gd 는 PNG, JPEG & WBMP 그림을 만들어 냅니다.
그러므로 gd 설치시에는 libpng, zlib 등을 함께 설치할 것을 권장 합니다. GIF 은 라이센스 문제가 있어 포함이 안됩니다. 

make시 다음과 같은에러 발생시
zlib를 다시 설치한다.( ./configure -s )
/usr/local/lib/libz.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1
}}}

!!!freetype 2 설치
{{{
글짜를 그릴 때 쓰는 라이브러리 입니다.

wget http://ftp.superuser.co.kr/pub/etc/freetype-2.2.1.tar.bz2
tar xvfj freetype-2.2.1.tar.bz2
cd freetype-2.2.1
./configure && make && make install
cd ..
}}}

!!!libjpeg 설치
{{{
jpg 포맷을 다루는 라이브러리 입니다.

wget http://ftp.superuser.co.kr/pub/etc/jpegsrc.v6b.tar.gz
tar xvfz jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config.guess ./  
cp /usr/share/libtool/config.sub ./  
./configure --enable-shared --enable-static
make && make test
mkdir /usr/local/man/man1
make install
cd ..

위 설치법에서 특별한 것은 중간에 /usr/local/man/man1이라는 디렉토리를 생성합니다. 
이유는 make install 하면 /usr/local/man/man1 디렉토리가 없다고 멘 페이지가 설치가 되지 않는다는 에러가 납니다. 
}}}

!!!php 설치
* 컴파일 설치 5.2.10
{{{
wget http://kr.php.net/get/php-5.2.10.tar.gz/from/this/mirror
tar -xvzf php-5.2.10.tar.gz
cd php-5.2.10

./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs \
              --with-openssl --with-mcrypt --with-gd --with-ttf --with-gettext --with-zlib \
              --with-gdbm=/usr \
              --with-jpeg-dir=/usr/src \
              --with-png-dir=/usr/lib \
              --with-freetype-dir=/usr/include/freetype2  \
              --with-libxml-dir=/usr/local/lib \
              --with-exec-dir=/usr/bin  \
              --with-config-file-path=/usr/local/php5 \
              --with-mysql=/usr/local/mysql \
              --with-mysqli=/usr/local/mysql/bin/mysql_config \
              --with-sqlite=shared \
              --enable-pdo=shared \
              --with-pdo-sqlite=shared \
              --with-pdo-mysql=shared,/usr/local/mysql \
              --enable-sockets --enable-sysvsem=yes --enable-sigchild \
              --enable-sysvshm=yes --enable-ftp  --enable-magic-quotes --enable-gd-native-ttf \
              --enable-inline-optimization  --enable-bcmath  --enable-soap --enable-maintainer-zts \
              --enable-debug=no --enable-mbstring --enable-wddx --enable-mbregex --enable-exif --enable-calendar 

#64bit 시스템일경우 아래옵션 추가
--with-libdir=lib64 

make && make install
cp php.ini-dist /usr/local/php5/php.ini
cd ..
}}}

* 각종오류 관련 자료
{{{
/usr/lib/ld : connot find -lltdl 
http://kldp.org/node/86203

/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
http://www.howtoforge.com/forums/archive/index.php/t-4276.html

64bit 시스템에서 mysql라이브러리를 못찾을때
http://bugs.php.net/bug.php?id=36073&edit=1
}}}

!!!path 설정
{{{
vi /etc/profile
#PHP
PHP_HOME=/usr/local/php5
PATH=$PATH:$PHP_HOME/bin
}}}

!!!php.ini 설정
{{{
#extension관련 설정 5.2.x
extension_dir = "/usr/local/php5/lib/php/extensions/no-debug-zts-20060613/"

#pdo관련 설정
extension=pdo.so
extension=pdo_mysql.so
}}}

!!!아파치 설정
{{{
vi /usr/local/apache2/conf/httpd.conf
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#LoadModule는 자동으로 추가 될때도 있으니 주의

PHP 4는:
LoadModule php4_module libexec/libphp4.so

PHP 5는:
LoadModule php5_module libexec/libphp5.so

#php 확장자 추가
AddType application/x-httpd-php .php .phtml .html
#phps를 하이라이트된 PHP 소스로 보여줌
AddType application/x-httpd-php-source .phps
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
}}}

!!!Zend Optimizer
!다운로드
{{{
34 bit
wget http://downloads.phpchina.com/zend/optimizer/3.3.3/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
tar -xvzf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
cd ZendOptimizer-3.3.3-linux-glibc23-i386
./install

64 bit
wget http://downloads.phpchina.com/zend/optimizer/3.3.3/ZendOptimizer-3.3.3-linux-glibc23-x86_64.tar.gz
tar -xvzf ZendOptimizer-3.3.3-linux-glibc23-x86_64.tar.gz
cd ZendOptimizer-3.3.3-linux-glibc23-x86_64
./install

대화상자의 내용을 확인하면서 진행 하면 됨
주의 사항 : php.ini의 경로를 입력 하라고 하면 /usr/local/php5 와 같이 넣어주면 된다.
}}}

!아래와 같은 내용이 phpinfo(); 함수 수행시 나오면 성공
{{{
    with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
    with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies
}}}

!!!eAccelerator 설치(캐싱)
{{{
wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2

tar -xvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3


phpize
./configure --enable-eaccelerator=shared
make
make install

[zend] 설정 위에 있어야 함

[eaccelerator]
;extension="eaccelerator.so"
zend_extension="/usr/local/php5/lib/php/extensions/no-debug-zts-20060613/eaccelerator.so"
zend_extension_ts="/usr/local/php5/lib/php/extensions/no-debug-zts-20060613/eaccelerator.so"
; eAccelerator가 사용할 공유 메모리량. 단위 MBytes.
; 0을 지정하면 OS 기본값. default = 0
eaccelerator.shm_size="64"

eaccelerator.cache_dir="/var/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"

; 캐싱할 php 파일을 지정한다. *.php *.html *.php3 처럼 지정할 수 있으며 "" 로 비워두면 모든 php 파일이 캐싱된다.
eaccelerator.filter="*.php *.html"

; 한 유저가 최대 사용할 수 있는 메모리량 메모리 크기를 bytes단위로 표시한다. (예. 10240, 10K, 1M).  0은 제한 없음
eaccelerator.shm_max="0"

; 새 스크립트 파일을 캐싱할만한 공유 메모리가 없다면, ssh_ttl 초동안 액세스가 없는 모든 스크립트를 삭제한다. default = 0. 0은 삭제안함을 의미
eaccelerator.shm_ttl="0"

; 이 설정은 위의 shm_ttl 설정과 비슷하다.
; 지정한 초보다 오래전에 만들어진 스크립트를 제거한다.
; 즉, shm_ttl은 액세스시간에, shm_prune_period는 생성시간에 따라 삭제한다.
; default = 0. 0은 삭제안함을 의미
eaccelerator.shm_prune_period="0"

; 컴파일된 스크립트를 디스크에 캐싱할 것인지 여부.
; session data와 content 캐싱은 이설정과 무관. default = 0.
; 0이면 캐싱을 위해 디스크와 메모리를 모두 사용한다.
eaccelerator.shm_only="0"

;캐시된 내용 압축 여부
eaccelerator.compress="1"

;압축 레벨 지정. 9는 최대 압축 레벨
eaccelerator.compress_level="9"

;아래 path가 정확하지 않을시 control.php에서 에러가 발생 됨
eaccelerator.allowed_admin_path = "/usr/local/apache2/htdoc/control.php"



mkdir /var/eaccelerator
chmod 0777 /var/eaccelerator


php -v 체크하기
}}}

!!!XDebug 설치(무한루프를 막아줌/memory_limit에서도 막아줌)
{{{
wget http://www.xdebug.org/files/xdebug-2.0.4.tgz

tar -xvf xdebug-2.0.4.tgz
cd xdebug-2.0.4

phpize
./configure
make
make install

php.ini에 설정
extension=xdebug.so
}}}

!!!Pear 설치
{{{
php5.x  /usr/local/php5/bin/pear 스크립트가 존재
 
pear list                                   : 설치된 package 목록
pear remote-list                       : pear.php.net 에 있는 Package List
pear install [package명]           : 설치
pear uninstall [package명]       : 제거
pear remote-info [package명]  : pear.php.net 에 있는 Package Info
pear upgrade-all                       : 설치된 모든 패키지 업그레이드 
pear list-all                              : 설치 안된것까지 포함한 모든 사용가능 목록 출력
pear install Net_Whois              : 해당 패키지를 다운받아 설치.
pear remote-info  DB                : 원격서버의 DB 패키지의 정보.

./pear install DB

}}}