Tag Archives: DBA

Accelerates the performance of PHP on your servers – Install xCache

XCache is an open-source cacher that can significantly boost the performance of PHP code on your servers. It keeps the compiled form of PHP scripts into the system cache or RAM and uses that compiled version straight from the server cache, If compiled version is found in cache the PHP code compilation is skipped that saves time and delivers optimal performance.

In order to install xCache on CentOS you need to following the following steps.

1) Login to your server or VPS using root credentials.

2) Make user you have all the libraries and tools required to complete the installation:
yum -y install php-devel gcc make

3) Download the latest tarball of xcache
cd /opt
wget http://xcache.lighttpd.net/pub/Releases/3.1.0/xcache-3.1.0.tar.gz

4) Uncompress the source code
tar zxvf xcache-3.1.0.tar.gz
cd xcache-3.1.0

5) Now you need to build the
phpize –clean

You will get the output similar to the following.
Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212

6) Now execute the configuration script
./configure –enable-xcache && make

The above command will take a minute or so to complete and produce significant screen out. At the end you will see message
Build complete.
Don’t forget to run ‘make test’.

7) Now you need to publish the compiled XCache:

make install

8) For administration panel of XCache you will need to generate a password encrypted with md5.

echo -n “DmbAdm2014″|md5sum
52e4557e634f2ab84a967b17be449d06 –

9) Now you need to update php.ini file with the details similar to the following

vi /etc/php.ini
extension = /usr/lib64/php/modules/xcache.so
xcache.admin.user = “admin”
xcache.admin.pass = “52e4557e634f2ab84a967b17be449d06″

xcache.size = 32M
xcache.shm_scheme = “mmap”

; set to cpu count (cat /proc/cpuinfo |grep -c processor)
xcache.count = 4
xcache.slots = 8K

; ttl of the cache item, 0=forever
xcache.ttl = 0
xcache.gc_interval = 0

xcache.var_size = 8M
xcache.var_count = 1
xcache.var_slots = 8K
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300

xcache.test = Off
xcache.readonly_protection = On
xcache.mmap_path = “/tmp/xcache”
xcache.coredump_directory = “”

xcache.cacher = On
xcache.stat = On
xcache.optimizer = Off

xcache.coverager = On
xcache.coveragedump_directory = “”

10) Now you can test if XCache is enabled by running the phpinfo() function and look for something similar to:
with XCache v2.0.1, Copyright (c) 2005-2013, by mOo