We’re thrilled to announce EarlyDog, our fully managed hosting on Google Cloud servers EarlyDog: managed hosting on Google Cloud

← ServerPilot Docs

How to Install the PHP XCache Extension

In the examples shown, replace "5.X" with your app's PHP version (for example, "5.6").

The XCache extension is a third-party PHP opcode cache.

PHP versions 5.5 and above include a built-in, high-performance, reliable opcode cache. The XCache extension was written before PHP had a built-in opcache. You should only use this extension if you have a specific need for it.

Installing XCache on PHP 5.5 and 5.6

To install this extension, SSH in to your server as root and install the packages required to build the XCache extension.

sudo apt-get -y install gcc make autoconf libc-dev pkg-config

Next, download XCache, extract it, and change to the XCache directory.

wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz
tar xzf xcache-3.2.0.tar.gz
cd xcache-3.2.0

Now, compile, install, and restart PHP. To install for multiple PHP versions, repeat the steps below for each PHP version.

PATH=/opt/sp/php5.X/bin:$PATH ./configure --enable-xcache
sudo make install
sudo bash -c "echo extension=xcache.so > /etc/php5.X-sp/conf.d/xcache.ini"
sudo service php5.X-fpm-sp restart

Verifying the Installation

You can verify XCache is installed correctly by running the command:

php5.X-sp -i | grep xcache

You should see the following output:

xcache.coredump_directory => no value => no value
xcache.disable_on_crash => Off => Off
xcache.experimental => Off => Off
xcache.test => Off => Off
xcache.admin.enable_auth => On => On
xcache.allocator => bestfit => bestfit
xcache.cacher => On => On
xcache.count => 1 => 1
xcache.gc_interval => 0 => 0
xcache.mmap_path => /dev/zero => /dev/zero
xcache.readonly_protection => Off => Off
xcache.shm_scheme => mmap => mmap
xcache.size => 0 => 0
xcache.slots => 8K => 8K
xcache.stat => On => On
xcache.ttl => 0 => 0
xcache.var_allocator => bestfit => bestfit
xcache.var_count => 1 => 1
xcache.var_gc_interval => 120 => 120
xcache.var_maxttl => 0 => 0
xcache.var_namespace => no value => no value
xcache.var_namespace_mode => 0 => 0
xcache.var_size => 0 => 0
xcache.var_slots => 8K => 8K
xcache.var_ttl => 0 => 0

Installing XCache on PHP 7

The XCache extension does not currently work with PHP 7. If you attempt to install it on PHP 7, you will encounter errors building the extension. As soon as the extension is updated to work with PHP 7, you will be able to install it.

Uninstalling the XCache Extension

To uninstall this extension, as root run the command:

sudo rm /etc/phpX.Y-sp/conf.d/xcache.ini

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart
Last updated: February 26, 2018

Launch your first site in 5 minutes