[HowTo] Install XCache For PHP5 In CentOS

Instead using Alternative PHP cache (APC), we can use PHP XCache for PHP caching system. XCache is an open-source opcode cacher, to accelerates PHP performance on servers. It optimize performance by removing the compilation time of PHP scripts with caching the compiled state of PHP scripts into the shm (RAM) or memory and uses the compiled version straight from the RAM or memory. This will increase the rate of page generation time by up to 5 times as it also optimizes many other aspects of php scripts and reduce server load.

To install PHP XCache on Linux, especially CentOS, follow the steps below:
1. Download XCache:

wget http://xcache.lighttpd.net/pub/Releases/1.2.1/xcache-1.2.1.tar.gz

2. Extract it:

tar -zxvf xcache-1.2.1.tar.gz
cd xcache-1.2.1

3. Compile and install XCache:

./configure --enable-xcache
make install

4. Configure php.ini to include XCache:

zend_extension = /usr/lib/php/modules/xcache.so
; For 64bit version => /usr/lib64/php/modules/xcache.so

xcache.admin.auth = On
xcache.admin.user = "mOo"
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = ""

xcache.shm_scheme =        "mmap"
xcache.size  =               32M
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  =            0M
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

5. Restart Apache:

/etc/init.d/httpd restart

6. Check it in PHP info.

XCache Official Page

Give me your feedback

This site uses Akismet to reduce spam. Learn how your comment data is processed.