Integrating XCache Into PHP5 (Fedora 13 & Lighttpd)

Version 1.0
Author: Falko Timme
Follow me on Twitter

This guide explains how to integrate XCache into PHP5 on a Fedora 13 system (with Lighttpd). 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 Fedora 13 server with the IP address where Lighttpd and PHP5 are already installed and working (as explained in this tutorial: Installing Lighttpd With PHP5 And MySQL Support On Fedora 13). I'll use Lighttpd's default document root /var/www/lighttpd 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/lighttpd:

vi /var/www/lighttpd/info.php

Afterwards, we call that file in a browser:

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

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

If you see that another PHP opcode cacher such as eAccelerator or APC is installed, you must remove it before you install APC:

For eAccelerator:

yum remove php-eaccelerator

For APC:

yum remove php-pecl-apc

Restart Lighttpd afterwards:

/etc/init.d/lighttpd restart


3 Installing XCache

Unfortunately XCache isn't available as an rpm package for Fedora 13, therefore we have to build it from the sources. First we install all packages that we need to build XCache:

yum install php-devel
yum groupinstall 'Development Tools'
yum groupinstall 'Development Libraries'

Next we download and uncompress the latest XCache version:

cd /tmp
tar xvfz xcache-1.3.0.tar.gz

Then we go to the new XCache source directory...

cd xcache-1.3.0

... and build XCache as follows:

./configure --enable-xcache
make install

Next we copy xcache.ini to the /etc/php.d directory:

cp xcache.ini /etc/php.d

Now we must configure XCache. The configuration options are explained here: The least you should do is enable extension = and disable all zend_extension lines; furthermore, set xcache.size to a size (in MB) > 0 to enable XCache:

vi /etc/php.d/xcache.ini
;; install as zend extension (recommended), normally "$extension_dir/"
;zend_extension = /usr/local/lib/php/extensions/non-debug-non-zts-xxx/
; zend_extension_ts = /usr/local/lib/php/extensions/non-debug-zts-xxx/
;; For windows users, replace with php_xcache.dll
;zend_extension_ts = c:/php/extensions/php_xcache.dll
;; or install as extension, make sure your extension_dir setting is correct
extension =
;; or win32:
; extension = php_xcache.dll
xcache.size  =                60M

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

/etc/init.d/lighttpd 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:


Share this page:

0 Comment(s)