This should work in 5.2.x, 5.3.x and now even 5.4.x.
I’ll try to make this one easy since I’m assuming you’ve installed an extension before (Read my eAccelerator article if you haven’t).
First, you’ll want to make sure you’re not running eAccelerator or APC already. If you are, make sure they’re disabled before continuing.
Next, you need to grab the sources for XCache and build them.
wget http://insert.actual.url.here/xcache-x.x.x.tar.gz tar zxvf xcache-x.x.x.tar.gz cd xcache phpize ./configure ; make ; make install
It builds cleanly on any machine I’ve tested, so you shouldn’t get any errors. Once you’ve ensured no errors were shown, you can proceed to configuration. You’ll need to copy the contents of xcache.ini either into php.ini (append, don’t overwrite!) or just copy xcache.ini into /etc/php.d or your distribution’s equivalent directory.
To properly configure it, there are a few sections of XCache configuration to edit (I’ll explain after):
[xcache-common] extension = xcache.so [xcache.admin] xcache.admin.enable_auth = On xcache.admin.user = "admin" xcache.admin.pass = "c3aef7f3f2f88s35cc26509ade9837a" [xcache] xcache.shm_scheme = "mmap" xcache.size = 128M xcache.count = 1 xcache.slots = 8K xcache.ttl = 0 xcache.gc_interval = 0 xcache.var_size = 4M xcache.var_count = 1 xcache.var_slots = 8K xcache.var_ttl = 0 xcache.var_maxttl = 0 xcache.var_gc_interval = 300 xcache.readonly_protection = Off xcache.mmap_path = "/dev/zero" xcache.coredump_directory = "" xcache.cacher = On xcache.stat = On xcache.optimizer = On xcache.test = Off xcache.experimental = Off [xcache.coverager] xcache.coverager = Off xcache.coveragedump_directory = ""
We’ll start from the top:
extension - This is the same format as any other extension line, and is the most important.
xcache.admin.enable_auth - Set this to On. Trust me you’ll love it. The next two options are self explanatory. The first being the user to authenticate to the admin page with, and the second is an md5sum of your desired password.
xcache.size - This is the maximum size of available SHM space for XCache. The default max SHM size for most Linux distros is 32M. Set a higher value to kernel.shmmax to increase this.
xcache.ttl - This is the “time-to-live” and determines the maximum age of a cached object.
xcache.gc_interval - This defines the garbage collection interval (how often cache is cleaned).
xcache.var_* - Most of these settings should remain the same. You can increase the var size if you have a very heavy PHP site, but don’t increase the GC interval unless you know what you’re doing.
xcache.cacher - Enable the opcode cacher. Do it.
xcache.optimizer - Enable the optimizer. Do this also!
Now you want to test and make sure it’s properly configured. Usually, you can just run ‘php -v’ to show the version and you’ll see an XCache version appended to the bottom, but it depends on the implementation of PHP you’re running.
The final step is to place the admin directory in a public folder somewhere under your DocumentRoot. Assuming you’re still sitting in the source directory for XCache, and your site (example.com) is hosted inside /var/www/example.com, you can do that like this:
cp -a admin/ /var/www/example.com/XCacheAdminPerhaps also adjust permissions accordingly..
Now you just need to restart your PHP interpreter (Apache or Spawn-FCGI or PHP-FPM, for example). When you visit www.example.com/XCacheAdmin , you will be presented with a login prompt, into which you enter the user/pass combo you chose before. This will show you statistics and usage of the cache.