Skip to main content

XCache setup

xCache is a php bytecode caching program to speed up script execution. Like, for example, eAccelerator or PHP-APC.

Install xcache to the server using the standard command:

  # aptitude install php5-xcache 

Basic cache settings

Open the /etc/php5/mods-available/xcache.ini file. All parameters are grouped. At the moment we need a group [xcache]

xcache.size = 32M

This directive specifies the total amount of memory for the cache. The default is 16 megabytes.

xcache.count = 1

Indicated by the number of processors (cores). Two cores - set 2. And so on.

xcache.ttl = 0

Cache lifetime Sometimes it may be necessary to clear the cache after a certain period of time. The value is specified in seconds.

Consider the parameters required for caching variables.

xcache.var_size = 8M

The total amount of memory allocated to the variable cache. By default, 0 is disabled.

xcache.var_count = 1

This variable is similar to xcache.count.

xcache.var_ttl = 0

Here you can also draw an analogy with the variable xcache.ttl: sets the lifetime of the variable cache.

xcache.var_maxttl = 0

This variable indicates the maximum cache lifetime.

XCache Optimizer

As an addition, you can enable xcache optimizer.

  xcache.optimizer = on 

Admin panel for xCache

xCache comes with a control panel that allows you to view statistics. I have a bunch of nginx + php-fpm, an example will be written with this in mind.

First of all, configure nginx. This will require the use of alias for location.

  location / x / {
 alias / usr / share / xcache / admin /;

 location ~ \ .php $ {
 fastcgi_index index.php;
 fastcgi_pass unix: /run/php-fpm.sock;
 include fastcgi_params;
 fastcgi_param PHP_ADMIN_VALUE "open_basedir = / usr / share / xcache / admin /: / var / php-temp-dir /";
 fastcgi_param SCRIPT_FILENAME $ request_filename;


We register the configuration for any virtual host, restart nginx: service nginx reload .

Next, in the browser, open the page http: // /x/mkpassword.php . replace the address of your site for which you created an alias.

Using this script, you need to create the md5 password hash that will be used for authentication in the xCache admin panel. It is enough to specify a password, click the "Send request" button and copy the result.

After all these actions, open the /etc/php5/mods-available/xcache.ini file, edit the necessary parameters in the [xcache.admin] group.

xcache.admin.user = "username"

Specify the name of the user who will have access to the admin panel.

xcache.admin.pass = "..."

Here in quotes you need to specify the user md5-hash of the password.

Save the edited file and restart apache, php-cgi or php-fpm.

Now the xcache admin should be available at Try to log in and view statistics.

How do you rate the article?
Звёзд: 1Звёзд: 2Звёзд: 3Звёзд: 4Звёзд: 5 (No ratings yet)

” 2 Comments “ Setting up xCache

  1. Xcache in the debian of the old version 2.0.0, and already 3.2.0 in the yard. How to deal with this - compile from source? I don't want to use dotdeb for one xcache. he pulls the whole php

Add a comment

Your email will not be published.