Optimización PHP con Xcache en Ubuntu server
Servidor

Optimización PHP con Xcache en Ubuntu server

09 Aug, 2016 • 3 min de lectura

La configuración es por medio de apt-get, configurando el .ini y reiniciando el servidor. Primero compruebo la instalación actual de php y los tiempos de ejecución de los scripts.

# php -v</p>
PHP 5.5.9-1ubuntu4.19 (cli) (built: Jul 28 2016 19:31:33)   
Copyright (c) 1997-2014 The PHP Group  
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies  
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

Para instalar xcache:

# apt-get install php5-xcache</p>
0 upgraded, 1 newly installed, 2 to remove and 2 not upgraded.  
Need to get 109 kB of archives.  
After this operation, 90.1 kB of additional disk space will be used.  
Do you want to continue? [Y/n] y  
Get:1 http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu/ trusty/universe php5-xcache amd64 3.1.0-2 [109 kB]  
Fetched 109 kB in 0s (657 kB/s)   
(Reading database ... 39119 files and directories currently installed.)  
Removing php-apc (4.0.2-2build1) ...  
dpkg: warning: while removing php-apc, directory '/usr/share/doc/php-apc' not empty so not removed  
Removing php5-apcu (4.0.2-2build1) ...  
php5_invoke prerm: Disable module apcu for apache2filter SAPI  
php5_invoke prerm: Disable module apcu for cli SAPI  
Selecting previously unselected package php5-xcache.  
(Reading database ... 39098 files and directories currently installed.)  
Preparing to unpack .../php5-xcache_3.1.0-2_amd64.deb ...  
Unpacking php5-xcache (3.1.0-2) ...  
Setting up php5-xcache (3.1.0-2) ...  
php5_invoke: Enable module xcache for apache2filter SAPI  
php5_invoke: Enable module xcache for cli SAPI

Después revisar y ajustar más tarde la configuración del .ini

# nano /etc/php5/mods-available/xcache.ini

</p> Reiniciar Apache:

# service apache2 restart</p>
* Restarting web server apache2

Comprobar la carga de módulos de php

# php -v</p>
PHP 5.5.9-1ubuntu4.19 (cli) (built: Jul 28 2016 19:31:33)   
Copyright (c) 1997-2014 The PHP Group  
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies  
 with XCache v3.1.0, Copyright (c) 2005-2013, by mOo  
 with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies  
 with XCache Optimizer v3.1.0, Copyright (c) 2005-2013, by mOo  
 with XCache Cacher v3.1.0, Copyright (c) 2005-2013, by mOo  
 with XCache Coverager v3.1.0, Copyright (c) 2005-2013, by mOo

Tras varias pruebas de carga comparando xcache y opcache en el caso de Magento 1.9.1, Opcache ha resultado ofrecer la carga de código de página entre un 33 y un 50% más rápida, claro está para esta configuración en particular, i.e. Ubuntu 14, PHP 5.5, con 200MB xcache… Por lo que he vuelto a Opcache, des-habilito el módulo de xcache:

# php5dismod xcache</p>
//vuelta a opcache  
# php5enmod opcache

Ref: http://xcache.lighttpd.net/

Ejemplo de configuración de opcache para Magento : https://gist.github.com/tegansnyder/608185c9aeb11c10d8ae

Categorías: Servidor
Etiquetas: