In this tutorial we will show you how to install of XCache on centOS. For those of you who didn’t know, 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 server load. In this tutorial we will show you how to install xCache on a CentOS.
Install XCache for PHP on CentOS
Step 1. First add EPEL yum repository your system.
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-1.noarch.rpm
Step 2. Install XCache for PHP.
yum install php-xcache xcache-admin
Step 3. Configuring of XCache for PHP.
nano /etc/php.d/xcache.ini [xcache-common] extension = /usr/lib64/php/modules/xcache.so [xcache] 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
You can modify the settings in the xcache.ini file according to your needs. Detailed explanation about these settings you can find at the xCache official wesbsite.
Step 4. Restart your Nginx web server.
sudo service nginx restart
At this point xCache should be successfully installed on your server. You can confirm that by executing the following command:
php -v PHP 5.5.20 (cli) (built: Dec 31 2014 00:46:99) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies with XCache v3.2.0, Copyright (c) 2005-2014, by mOo with XCache Cacher v3.2.0, Copyright (c) 2005-2014, by mOo
Congratulation’s! You have successfully installed XCache for PHP. Thanks for using this tutorial for installing XCache in CentOS system. For additional help or useful information, we recommend you to check the official XCache web site.