Installing xcache on Plesk can be a bit of an adventure, especially on FreeBSD, since Plesk doesn’t include a lot of the php sources you may require to get this done.
Download xcache 1.2.1 and php-4.4.4 (or whatever version matches what you require, you can check this by running a phpinfo.php script on the webserver)
A way around this is to download the version of php you require (in this case, php-4.4.4, which matches that running on Plesk 8.0.1 on FreeBSD). Once you’ve got this, you should configure and make php, then install the build environment:
Allow the scripts inside the /scripts directory to be executed:
chmod +x scripts/*
Now you have a build environment for php ready to go, and you can start to compile xcache. Here we use the php-4.4.4 directory to run our php-config from. Then we copy the modules to the php modules directory for Plesk.
./configure --enable-xcache --enable-xcache-optimizer --with-php-config=../php-4.4.4/scripts/php-config
cp modules/xcache.* /usr/local/psa/apache/libexec/php/
Edit your php.ini to be similar to the following. This is set up for a dual CPU system, and is set to use 96 megs of cache, which might be a bit too high for low-traffic servers.
Change the YOUR_USERNAME_HERE area to include your username you would like to use for the admin, and YOUR_MD5_PASS_HERE to be an md5 hash of the password you would like to use. You can get the MD5 password hash by doing the following:
md5 -s somepassword
;; install as zend extension (recommended), normally "$extension_dir/xcache.so"
zend_extension = /usr/local/psa/apache/libexec/php/xcache.so
xcache.admin.auth = On
xcache.admin.user = “YOUR_USERNAME_HERE”
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = “YOUR_MD5_PASS_HERE”
; 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 = 96M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
xcache.count = 2
; just a hash hints, you can always store count(items) > slots
xcache.slots = 8K
; ttl of the cache item, 0=forever
xcache.ttl = 86400
; interval of gc scanning expired items, 0=no scan, other values is in seconds
xcache.gc_interval = 3600
; same as aboves but for variable cache
xcache.var_size = 8M
xcache.var_count = 2
xcache.var_slots = 8K
; default ttl
xcache.var_ttl = 3600
xcache.var_maxttl = 86400
xcache.var_gc_interval = 300
xcache.test = Off
; N/A for /dev/zero
xcache.readonly_protection = Off
; 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 = “/dev/zero”
; leave it blank(disabled) or “/tmp/phpcore/”
; make sure it’s writable by php (without checking open_basedir)
xcache.coredump_directory = “/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 = Off
; ini only settings
; make sure it’s readable (care open_basedir) by coverage viewer script
; requires xcache.coverager=On
xcache.coveragedump_directory = “”
Now you need to copy the admin files to some location on your server :
cp -R admin ~someuser/httpdocs/xcache_admin
chown someuser:psaserv *
cp config.php.example config.php
Edit the config.php if you want to use alternate login methods.
You can now restart Apache and you should be able to monitor xcache details from your new xcache_admin location using the login and password you set in php.ini.
* I’ve set var_size to 8M, but it doesn’t seem to ever matter, it never allocates any variables. I’m not sure what the deal with that is.
* I’ve tried to set xcache_count to 1 or 2, 2 seems to be good on a dual CPU machine, although there have been reports that it crashes or doesn’t run as fast. I’m not sure. Perhaps if you have a single CPU machine and try to set that to 2, you might end up in tears.
* The ttl settings are not well tested since this install is quite young. However it seems to work quite well so far.