Install Xcache on Ubuntu 14.04.1 LTS and SilverStripe 3

 To optimize and accelerate website performance you can use an opcode cacher such as Xcache.  Bellow are the steps I took to get this installed.

 

Step 1

Install xcache

apt-get install php5-xcache

 

Step 2

Update config for xcache

sudo nano /etc/php5/mods-available/xcache.ini

Set a username and password

[xcache.admin]

xcache.admin.enable_auth = On

; Configure this to use admin pages

xcache.admin.user = "your_user_name"

; xcache.admin.pass = md5($your_password)

xcache.admin.pass = "{your_md5_password}"

 

Step 3

Restart apache

sudo apachectl configtest

if Syntax OK

sudo apachectl restart

 

Step 4

Verify Installation

php -v

 

Step 5

Copy admin to web accessible folder

mkdir /var/www/html/xcache/

(or wherever your webroot is)

cp -R /usr/share/xcache/htdocs/* /var/www/html/xcache/

http://example.com/xcache/
 

 

Step 6

Create url to clear Xcache for deploying code updates

mkdir /var/www/html/clear_xcache/

(or wherever your webroot is)

sudo nano /var/www/html/clear_xcache/index.php

Put this with an opening php tag in the file and save

//Clear xcache and redirect to current domain

    xcache_clear_cache(XC_TYPE_PHP);

    echo 'Cleared!';

    header("Location: http://".$_SERVER['HTTP_HOST']);

    die();

 

You can now clear your Xcache at http://example.com/clear_xcache/.  You will need to enter the username and password defined above.  Do this before you dev/build and ?flush=all