Home » Blogging, SEO Tips » How to install xCache from source

xCache is one of the fast, stable and widely used PHP accelerator and opcode cacher like APC (Alternative PHP Cache) and eAccelerator. It works by caching the compiled bytecodes form PHP scripts to avoid the overhead to parse and compile PHP source code on every page request reducing the server loads and boosts the performance of PHP scripts by increasing the pageload speed by 10 ~ 20 times.

The latest version (1.3.0) of xCache is compatible with latest PHP versions (from version 4.4 to 5.3) installed on Linux servers. There’s a unstable version available (Version 2.x), but that should be used for developing purpose only.

Let us install and activate the xCache from it’s source. This is easy and shouldn’t take more than 10 to 15 minutes. You need to be logged in as root and have SSH access to install. If you are on a VPS or Shared hosting, ask your host to install it for you.

1. Login to the server uaing SSH with root access

2. Go to local source file’s directory
cd /usr/local/src

3. Download the xCache Source Files
wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz

4. Extract the TAR archive
tar -zxf xcache-*.tar.gz

5. There will be a new directory created under “/usr/local/src” with the xCache version name. Go to it
cd xcache-1.3.0

6. Start PHP Building
phpize

At this point, you can choose to build xCache in another directory, like under “modules/xcache” directory. If so, create a directory called xcaxhe under “/usr/lib/httpd/modules/” and cd to it.

7. Configure and Enable the xCache (enter the full path to xCache source directory if you are installing it outside of the source directory.)
/xcache-1.3.0/configure –enable-xcache

8. Compile the source
make

9. Install the xCache
make install

If everything went okay, the installation will be done. Note down the paths to xcache.so file.

10. xCache now need to configured in php.ini file. Normally its located in “/usr/local/lib” directory. You can also use “locate php.ini” command to locate it. You can use “pico” command to edit the php.ini file, but the best solution is to use a windows based tool called WinSCP.

Put the following into bottom of your php.ini file

[xcache-common]
;; install as zend extension (recommended)
;;zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-xxx/xcache.so
;; install as zend extension with thread-safe
; zend_extension_ts = /usr/local/lib/php/extensions/non-debug-zts-xxx/xcache.so
;; install as PHP extension (extension_dir must be set to the full path to xcache.so)
extension = /full/path/to/xcahe/installation/xcache.so

[xcache.admin]
xcache.admin.user = "admin"
xcache.admin.pass = md5($your_password)

[xcache]
xcache.shm_scheme = "mmap"
xcache.size = 16M
xcache.count = 1
xcache.slots = 8K
xcache.ttl = 0
xcache.gc_interval = 0

xcache.var_size = 0M
xcache.var_count = 1
xcache.var_slots = 8K
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300

xcache.test = Off
xcache.readonly_protection = Off
xcache.mmap_path = "/dev/zero"
xcache.coredump_directory = ""
xcache.cacher = On
xcache.stat = On
xcache.optimizer = Off

[xcache.coverager]
xcache.coverager = Off
xcache.coveragedump_directory = ""

11. Restart the apache webserver
/etc/init.d/apache* restart

12. Ensure that xCache is installed, loaded and working by looking at your phpinfo page. There should be a new block for xCache with opcode cache enabled.

xCache

xCache Block

1 Comment

  1. Joanne Iden says:

    I seriously enjoyed this post. We (as a community), appreciate it. I own a comparable blog on this subject. Do you mind if I link to this posting on my web site?

Leave a Reply