Skip to main content

xCache Installation on XAMPP

To improve your PHP performance you need to use some caching tool. Like other scripting language php code also interpreted. The middle level code is being created by php code also i.e. known as opcode. So every time your php code executed and it generates opcode. There are some caching tool available which can cache opcode which increases our php script performance. I always prefer XCache which is good and easy to use. XCache is normally for linux platform but now it is avalible for windows also.To install XCache on your windows platform specially with XAMPP there are some very easy steps you need to follow.Following are the steps for xCache Installation on XAMPP(On windows based php distribution )

Install xCache on XAMPP

Download appropriate version of  XCache for your windows environment by this link XCache Download for windows
Unzip the folder you will get following files and folder within the distribution

Copy php_xcache.dll in your extension directory. In XAMPP it is in [Your Xampp path]/XAMPP/ext/
Now open your php.ini file (for xampp it is placed in [your xampp path]/xampp/bin/php.ini)
Put the following line in your xampp

zend_extension_ts = D:\Programs\xampp\php\ext\php_xcache.dll

Check for follwing setting of your php.ini and if it is not commented then please comment it

;zend_extension_ts = "D:\Programs\xampp\php\ext\php_xdebug-2.0.0-5.2.2.dll" ;XDEBUG
;zend_extension_ts = "D:\Programs\xampp\php\zendOptimizer\lib\ZendExtensionManager.dll"
;zend_extension_manager.optimizer_ts = "D:\Programs\xampp\php\zendOptimizer\lib\Optimizer"
;zend_optimizer.enable_loader = 0
;zend_optimizer.license_path =
; Local Variables:
; tab-width: 4
; End:
Now place follwing line of code in your php.ini file

xcache.admin.enable_auth = On
xcache.admin.user = "admin"
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = "21232f297a57a5a743894a0e4a801fc3"
; ini only settings, all the values here is default unless explained; select low level shm/allocator scheme implemenation
xcache.shm_scheme =        “mmap”
; to disable: xcache.size=0
; to enable : xcache.size=64M etc (any size > 0) and your system mmap allows
xcache.size  =               60M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
xcache.count =                 1
; just a hash hints, you can always store count(items) > slots
xcache.slots =                100K
; ttl of the cache item, 0=forever
xcache.ttl   =                 0
; interval of gc scanning expired items, 0=no scan, other values is in seconds
xcache.gc_interval =           0; same as aboves but for variable cache
xcache.var_size  =            4M
xcache.var_count =             1
xcache.var_slots =            8K
; default ttl
xcache.var_ttl   =             0
xcache.var_maxttl   =          0
xcache.var_gc_interval =     300

xcache.test =                On
; N/A for /dev/zero
xcache.readonly_protection = On
; for *nix, xcache.mmap_path is a file path, not directory.
; Use something like “/tmp/xcache” if you want to turn on ReadonlyProtection
; 2 group of php won’t share the same /tmp/xcache
; for win32, xcache.mmap_path=anonymous map name, not file path
xcache.mmap_path =    “anonymous”

; leave it blank(disabled) or “/tmp/phpcore/”
; make sure it’s writable by php (without checking open_basedir)
xcache.coredump_directory =   “D:\Programs\xampp\tmp”

; per request settings
xcache.cacher =               On
xcache.stat   =               On
xcache.optimizer =           On

; per request settings
; enable coverage data collecting for xcache.coveragedump_directory and xcache_coverager_start/stop/get/clean() functions (will hurt executing performance)
xcache.coverager =          On

; ini only settings
; make sure it’s readable (care open_basedir) by coverage viewer script
; requires xcache.coverager=On
xcache.coveragedump_directory = “D:\Programs\xampp\tmp”

In my setting I have given the path D:\Programs\xampp. You need to change it to your xampp directory

Now restart your XAMPP or if you are running normal php distributtion then please restart your Apache.
Open your php info page and to make sure whether xcache is installed or not please search for xcache. You will find follwoing line in your phpinfo page

If above data is shown on your phpinfo page then xcache is installed with your php.
To see the statistic your your cache you need to install xcache admin but not require. It is only to monitor your xache. To install the tool you only need to copy admin folder from your unzip xcache distribution(which already you have) to your webroot(in xampp it is htdocs folder). Now type http://localhost/admin.
It will ask for username and password. enter admin as username and admin as passoword.
You will see the following page

Happy caching 🙂
Thanks for reading the post



Support Me by Sharing This Article

Ankur Kumar Singh

I am a PHP programmer having some knowledge about Linux. I am always interested in web development and knowledge sharing. I am full time tech evangelist part time human being. :-)

Leave a comment/Ask Question

2 thoughts on “xCache Installation on XAMPP

  1. only enable coverager for development servers, on production servers this will hurt the performance (as stated in the comments). Alse set xcache.var_count and xcache.count to a number equal to the number of processorcores +1 of the machine where it runs on.