XCache is a free and open source PHP opcode cacher from xcache Mr.MOo. Using xCache you can have excellent performance of your PHP scripts 5 times faster than normal speed on your DigitalBerg ssd VPS.
Xcache optimises performance by removing the compilation time of PHP scripts by caching the compiled state of PHP scripts into the shm (Random access memory) and uses the compiled version forth from the Random access memory. This will speed up the rate of page generation time by up to 5 times as it also Speed up many other aspects of php scripts and reduces server load and keep the performance for more other traffic.
The XCache project is running by ‘mOo’ developer of Lighttpd. Lighttpd is one of the fastest webserver software and outperforms Apache and many other open source web serving projects so the same is being done to XCache.
Now its time for us to show you how to install xCache on a Digitalberg CentOS 7 VPS.
- First of all login to your DigitalBerg VPS with CentOS 7.x and up to date all packages first before install xcache.
yum -y update
- After, install the following important centos 7 packages:
yum install -y php-devel gcc make
- Once the php-devel and all other packages installed then proceed with the xCache download.
cd /opt wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz
- Unzip the downloaded tarball file command
tar -zxvf xcache-3.2.0.tar.gz
- Above command will create new xcache directory . Go to that directory with following command
cd xcache-3.2.0
Depending on your xcache version after installation please make sure sure check your version.
- Run the ‘phpize’ command to ready xCache as a PHP extension
phpize Configuring for: PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525
- Next step, you have to configure, compile and install xCache –
./configure --enable-xcache make make install
- The path of xcache.so is shown in the last line
Installing shared extensions: /usr/lib64/php/modules/
- Now, the path of the xCache extension is
/usr/lib64/php/modules/
- Now, you have to edit the PHP configuration file. Before execute you have to look for path
php -i |grep php.ini Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini
- Create a configuration file for xCache, and use the following lines
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
Please feed the right path of the xCache ext.
You can amend the settings in the xcache.ini file if you require more optimisation for php script. More explanation regarding xcache settings please follow this link xCache official.
- Restart your Apache web server :
systemctl restart httpd.service
- xCache should be successfully installed on your server and now use the following command to check the php version and xcache that installed?
php -v ------- PHP 5.4.16 (cli) (built: Oct 31 2014 12:59:36) 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
For sure if you are using our VPS, just ask our experts will help you to install 🙂 They are available 24×7 and will take care of your request immediately.