PHP 속도를 빠르게 해주는 xCache 설치 방법입니다.

1. XCache 설치

[root@yongbok ~]# cd /usr/local/src
[root@yongbok ~]# svn co svn://svn.lighttpd.net/xcache/trunk xcache-trunk
[root@yongbok ~]# cd xcache-trunk
[root@yongbok ~]# phpize –clean && phpize
[root@yongbok ~]# ./configure –with-php-config=which php-config –enable-xcache
–enable-xcache-constant –enable-xcache-optimizer
–enable-xcache-coverager –enable-xcache-assembler
–enable-xcache-encoder –enable-xcache-decoder –enable-static=yes
–enable-fast-install=yes
[root@yongbok ~]# make ; make install

Installing shared extensions:     /usr/local/lib/php/20060613/

make install 후 나오는 디렉토리는 PHP가 설치 된 환경에 따라 다를수 있습니다.

2. PHP.INI 설정
php.ini 파일을 열어 아래 구문들을 추가 합니다. (php.ini 파일도 설치 된 환경에 따라 다를수 있습니다.)

[root@yongbok ~]# vi /usr/local/apache2/conf/php.ini

[xcache-common]
; 모듈 로드
zend_extension = /usr/local/lib/php/20060613/xcache.so

[xcache.admin]
; xcache 관리자 설정
xcache.admin.auth = Off
xcache.admin.user = “ruo91”
; 비밀번호를 MD5로 설정 하려는 경우
; [root@yongbok ~]# md5 -s 123456
;  MD5 (“123456”) = e10adc3949ba59abbe56e057f20f883e
xcache.admin.pass = “e10adc3949ba59abbe56e057f20f883e”

[xcache]
xcache.shm_scheme = “mmap”
xcache.size = 256M
xcache.count = 1
xcache.slots = 8K
xcache.ttl = 3600
xcache.gc_interval = 300

; Same as aboves but for variable cache
; If you don’t know for sure that you need this, you probably don’t
xcache.var_size = 64M
xcache.var_count = 1
xcache.var_slots = 8K
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300

; N/A for /dev/zero
xcache.readonly_protection = Off

xcache.mmap_path = “/dev/zero”

xcache.cacher = On
xcache.stat = On

3. 아파치 재시작

[root@yongbok ~]# /usr/local/apache2/bin/apachectl restart

4. XCache 확인

[root@yongbok ~]# php -v

PHP 5.2.14 with Suhosin-Patch 0.9.7 (cli) (built: Jul 31 2010 13:02:08)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
with XCache v1.3.0, Copyright (c) 2005-2009, by mOo

참고
http://xcache.lighttpd.net/wiki/BuildingFromSource
http://nixcraft.com/web-servers/13180-help-xcache-eaccelerator.html
http://www.ibm.com/developerworks/kr/library/os-php-fastapps1/