Redhat / CentOS / Fedora Linux Install XCache for PHP 5

How do I install Xcache opcode cacher for PHP 5 under RHEL / CentOS version 5.0 server?

XCache is a open-source opcode cacher, which means that it accelerates the performance of PHP on servers. It optimizes performance by removing the compilation time of PHP scripts by caching the compiled state of PHP scripts into the shm (RAM) and uses the compiled version straight from the RAM. This will increase the rate of page generation time by up to 5 times as it also optimizes many other aspects of php scripts and reduce serverload.

Step # 1: Download xcahce source code

Use wget command to download latest stable release:
# cd /opt
# wget

Step # 2: Untar tar ball

Use tar command:
# tar -zxvf xcache-1.2.1.tar.gz
# cd xcache-1.2.1

Step # 2: Compile and install xcahce

Use phpize command to prepare xcache as a PHP extension for compiling:
# phpize
Configure, compile and install xcache:
# ./configure --enable-xcache
# make
# make install

Default installation location
  • 64 bit PHP module installed at /usr/lib64/php/modules/
  • 32 bit PHP module installed at /usr/lib/php/modules/

Step # 3: Create xcache.ini file

Under RHEL / CentOS, you place php modules configuration at /etc/php.d/ directory:
# cd /etc/php.d/
Create xcache.ini file:
# vi xcache.ini
Append configuration directives:

; change me - 64 bit php => /usr/lib64/php/modules/
; 32 bit php => /usr/lib/php/modules/ 
zend_extension = /usr/lib64/php/modules/

xcache.admin.auth = On
xcache.admin.user = "mOo"
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = ""

xcache.shm_scheme =        "mmap"
xcache.size  =               32M
xcache.count =                 1
xcache.slots =                8K
xcache.ttl   =              3600
xcache.gc_interval =         300

; Same as aboves but for variable cache
; If you don't know for sure that you need this, you probably don't
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

; N/A for /dev/zero
xcache.readonly_protection = Off

xcache.mmap_path =    "/dev/zero"

xcache.cacher =               On
xcache.stat   =               On

Save and close the file.

Alternatively, you can also copy default xcache.ini to /etc/php.d/
# cp xcache.ini /etc/php.d/
# vi /etc/php.d/xcache.ini

Restart your Apache web server:
# service httpd restart

If you are using Lighttpd web server, enter:
# service lighttpd restart

Step # 4: Make sure xcache is working

Type the following command for verification:
$ php -v

PHP 5.1.6 (cli) (built: Nov 20 2007 11:11:52) 
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
    with XCache v1.2.1, Copyright (c) 2005-2007, by mOo

You should see line “XCache v1.2.1, Copyright (c) 2005-2007, by mOo

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 22 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
22 comments… add one
  • Vu The Cuong Nov 26, 2007 @ 3:32

    Currently in Freebsd with php5, apache22 and xdebug2,
    xcache could not work with this combination.
    Could you figure out to use xcache with above ones?

  • 🐧 nixCraft Nov 26, 2007 @ 6:47

    IT only works with the following PHP cvs branches versions (php 5.0 is not supported, get php 5.2)
    PHP HEAD(6.x)

  • darshana nilantha Jan 2, 2008 @ 13:06

    For me this didn’t work untill I enabled two settings in php.ini file

    ; Directory in which the loadable extensions (modules) reside.
    extension_dir = “/usr/local/lib/php/extensions/no-debug-non-zts-20060613/”

    ; Dynamic Extensions

  • Ken Savage Apr 1, 2008 @ 5:04

    phpize isn’t found on my CentOS4 server.

    is there an alternate command?

  • 🐧 nixCraft Apr 1, 2008 @ 5:58


    Install php-devel package – which lets you compile dynamic extensions to PHP. This package has phpize command. Use yum command to install the same.

    • christoforos Aug 28, 2012 @ 14:18

      can you pls write exactly what command i have to give ?
      thank you very much

      • christoforos Aug 29, 2012 @ 11:05

        i gave command phpize => ” command not found”
        i gave command ” whereis phpize ” => and display => ” phpize: ”
        I gave command
        yum -y install php-devel
        but display that error

        Finished Dependency Resolution
        php-devel-5.1.6-39.el5_8.x86_64 from updates has depsolving problems
        –> Missing Dependency: php = 5.1.6-39.el5_8 is needed by package php-devel-5.1.6-39.el5_8.x86_64 (updates)
        Error: Missing Dependency: php = 5.1.6-39.el5_8 is needed by package php-devel-5.1.6-39.el5_8.x86_64 (updates)
        You could try using –skip-broken to work around the problem
        You could try running: package-cleanup –problems
        package-cleanup –dupes
        rpm -Va –nofiles –nodigest

        any ideas how to fix this ?
        thank you

        • Christoforos Aug 30, 2012 @ 9:00

          Is there any solution on that problem , without downgrade php :)

  • Son Nguyen Aug 28, 2008 @ 3:18

    Any RPM available for RHEL/CentOS 5?

  • Dharmaraj.A Sep 29, 2008 @ 15:35

    Very nice article. I installed with the help of this. In the middle I faced a problem when run the command ‘phpize’. I got an error like “bash: phpize: command not found”. Instead of ‘phpize’ I run ‘yum -y install php-devel’. Then again I continue from ‘phpize’. It’s installed. Thanx for your article.


  • Jase Nov 18, 2008 @ 9:54

    Could not get this to work with Apache, MPM Worker and PHP as fastcgi. PHP as mod_php works fine.

    Any extra requirement for fastcgi?

  • Sezai Feb 10, 2009 @ 12:26

    Can i use xcache and Eaccelerator at the same time? I use vbulletin also..

    PHP 5.2.6 (cli) (built: Sep 3 2008 06:59:35)
    Copyright (c) 1997-2008 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
    with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
    with the ionCube PHP Loader v3.1.32, Copyright (c) 2002-2007, by ionCube Ltd., and
    with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
    with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies

  • 🐧 nixCraft Feb 10, 2009 @ 13:31


    Only use one of them at a time. Xcache is the best.

  • Tada Burke Sep 23, 2009 @ 3:42

    Thank you for the great article! Oh, and in Step #3, there’s a funny typo: xcahce.ini :) Cheers

  • John Dec 22, 2009 @ 16:22

    Hi, I’m facing a few problems.
    1: After running #make install,
    What gets installed is: /usr/local/lib/php/extensions/no-debug-non-zts
    2: #cd /etc/php.d/… php.d is not a directoy in my setup. Where would I look alternitavely?

  • Scy Dec 25, 2009 @ 10:01


    • reza Nov 20, 2010 @ 4:31

      /etc/php5/conf.d/ AND /etc/php5/conf.d/ are not exist !!!!!!!!

  • Adrian Jul 26, 2010 @ 4:21


    Great article, after I followed your instructions which were clear I ran the command “php -v” and I got the output below, is my Xcache running as intended? Or do I need to make some adjustments? If so do you have any idea why I got the “PHP Warning: PHP Startup: memcache: Unable to initialize module” error?

    Best regards

    [root@server php.d]# php -v
    PHP Warning: PHP Startup: memcache: Unable to initialize module
    Module compiled with module API=20050922, debug=0, thread-safety=0
    PHP compiled with module API=20060613, debug=0, thread-safety=0
    These options need to match
    in Unknown on line 0
    PHP Warning: PHP Startup: memcache: Unable to initialize module
    Module compiled with module API=20050922, debug=0, thread-safety=0
    PHP compiled with module API=20060613, debug=0, thread-safety=0
    These options need to match
    in Unknown on line 0
    PHP 5.2.13 (cli) (built: Mar 2 2010 15:56:41)
    Copyright (c) 1997-2010 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
    with XCache v1.2.1, Copyright (c) 2005-2007, by mOo

    • akash Sep 6, 2010 @ 12:03

      Works really great…Vivek you rock man.

  • Ali Oct 23, 2010 @ 18:14

    Hi Vivek;
    Where do you think wrong?

    root@server [~]# php -v
    Failed loading /usr/lib64/php/modules/ /usr/lib64/php/modules/ cannot open shared object file: No such file or directory
    PHP 5.2.9 (cli) (built: Oct 20 2010 17:50:30)
    Copyright (c) 1997-2009 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

  • Jérôme Nov 19, 2010 @ 21:23


    I am instaling on a RedHat EL4 workstation, with php 5.1.3 and
    I have this pb :
    /usr/include/php/ext/date/lib/timelib_structs.h:24:28: error: timelib_config.h: No such file or directory

    a solution is to just use:

    export CFLAGS=-I/usr/include/php/ext/date/lib

    before the
    ./configure –enable-xcache

    • Jérôme Nov 19, 2010 @ 21:25

      Oups , as matter of fact is for php 5.1.2

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum