Integrating XCache Into PHP5 (Debian Etch & Apache2)

Version 1.0
Author: Falko Timme
Last edited 03/25/2008

This guide explains how to integrate XCache into PHP5 on a Debian Etch system (with Apache2). From the XCache project page: "XCache is a fast, stable PHP opcode cacher that has been tested and is now running on production servers under high load." It's similar to other PHP opcode cachers, such as eAccelerator and APC.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

I have tested this on a Debian Etch server with the IP address where Apache2 and PHP5 are already installed and working. I'll use Apache's default document root /var/www in this tutorial for demonstration purposes. Of course, you can use any other vhost as well, but you might have to adjust the path to the info.php file that I'm using in this tutorial.


2 Checking PHP5's Current State

First, before we install XCache, let's find out about our PHP5 installation. To do this, we create the file info.php in our document root /var/www:

vi /var/www/info.php


Afterwards, we call that file in a browser:

As you see, we have PHP 5.2.0 installed...

... but XCache isn't mentioned anywhere on the page:


3 Installing XCache

Unfortunately XCache is available as a Debian package only for Debian Lenny (testing) and Sid (unstable), but not for Etch. Therefore we will install the XCache package from Lenny. To do this, open /etc/apt/sources.list and add the line deb lenny main; your /etc/apt/sources.list could then look like this:

vi /etc/apt/sources.list

deb etch main
deb-src etch main

deb lenny main

deb etch/updates main contrib
deb-src etch/updates main contrib

Of course (in order not to mess up our system), we want to install packages from Lenny only if there's no appropriate package from Etch - if there are packages from Etch and Lenny, we want to install the one from Etch. To do this, we give packages from Etch a higher priority in /etc/apt/preferences:

vi /etc/apt/preferences

Package: *
Pin: release a=etch
Pin-Priority: 700

Package: *
Pin: release a=lenny
Pin-Priority: 650

(The terms etch and lenny refer to the appropriate terms in /etc/apt/sources.list; if you're using stable and testing there, you must use stable and testing instead of etch and lenny in /etc/apt/preferences as well.)

Afterwards, we update our packages database:

apt-get update

... upgrade the installed packages:

apt-get upgrade

(You might see the following question:

Do you want to upgrade glibc now? [Y/n] <-- Y


...and install php5-xcache:

apt-get install php5-xcache

That's it. Restart Apache, and you're done:

/etc/init.d/apache2 restart

Afterwards, open info.php again in a browser:

You should now see XCache mentioned on the page which means it has successfully been integrated and is working as expected:

If you want to change the XCache configuration, you can do so by editing /etc/php5/conf.d/xcache.ini. Don't forget to restart Apache afterwards. The configuration options are explained here:


4 Links

Share this page:

4 Comment(s)

Add comment


From: at: 2008-04-17 00:44:41

Just a sidenote = I installed the php5-xcache package on my Debian Lenny (testing) installation, and I had to manually add the following line to my /etc/php5/apache2/php.ini file:

One I did that, everything worked fine.  Thanks, Falko!

From: g at: 2010-09-03 09:13:08

but why I dont need to do changing php.ini eh?

 I just check out with this command; dpkg -l | grep php5

 php5-xcache seems ok! why do we need to add extension manually on php.ini anyway? I'm using Ubuntu here... linux flavour is nice!




From: jay at: 2010-12-02 22:04:31

 how do you access your admin page ? i installed using php5-xcache but not being able to find admin section

From: Chris at: 2011-05-11 13:06:36

For those Googling:

Admin setup: