How to Enable and Verify Xcache on a cPanel Server

How to Enable and Verify Xcache on a cPanel Server

Caching is an important part of the overall strategy to increase the speed of your website. While it may sound simple, there are actually many layers of caching – each of which is a separate subsystem. At the most forward facing level, we have HTML caching. A web application like WordPress dynamically generates its pages so simply grabbing the output and serving it the next time the same page is requested makes for a dramatic improvement. On the other hand, you have database catching which stores the data sets of queries in advance so that the database need not be touched each and every time for the same information.

Yet another kind of caching is known as “opcode caching”. As some of you know, languages can either be compiled or interpreted. You may have noticed the ease with which you can simply change PHP code and have your website magically reflect the results. This is because it is not a pure compiled language. If it were, you would need to spend huge amounts of time recompiling your code for every small change. Instead, it is compiled on the fly each time.

No one can deny the huge benefits of this kind of compilation – it makes rapid development and modification of code a reality. But it takes a hit on performance – the code has to be recompiled each time. This compiled code is called opcode. And this is where another type of caching comes into play. PHP caching or opcode caching has the potential to increase the speed of PHP delivery several times over. WHM already has an opcode cache called “Eaccelerator”. But many individuals prefer to use an opcode cache are known as xcache.

Luckily for us, this option is now available directly within WHM as part of the EasyApache package. This makes it as simple as clicking a checkbox. Let’s look at how to install it as well as verify the installation.

Installing Xcache

You can access the easy Apache module in WHM by finding it in the menu on the left-hand side:

easyapache

When you click it, you see a number of stored Apache configurations including the PHP version number. Out of all of these only one of the choices will be enabled. Since we don’t want to mess up anything and change an unrelated configuration, click the gear icon to the right-hand side of the enabled option – in my case, it’s labeled “default”.

From here, you’ll be presented with a series of screens asking you to verify the configuration of the macroenvironment such as the Apache version number as well as that of PHP. Skip all of these and don’t make any changes until you reach the third tab called “Short Options List”.

short options list

This screen will have a huge number of modules that can be enabled or disabled. Scroll down and search for the one called “Xcache”. By default, it will be disabled so simply place a checkmark in the box next to it. This will bring up a warning informing you that enabling xcache will automatically disable Eaccelerator which makes sense since we don’t want two opcode caching modules active at the same time.

xcache

Once enabled, scroll down to the bottom of the screen and click the button to save and build your Apache configuration. This should take several minutes and when it finally completes, you should have xcache enabled on your PHP operations.

Verifying the Install

Let’s check and see whether or not xcache has been installed correctly. Open up an SSH terminal and navigate to the folder containing the PHP.ini file using the following commands:

cd /usr/local/lib
vi php.ini

This will open up the “vi” editor with the PHP.ini file. To search for xcache, key in the following:

/xcache

And hit enter. As shown below, this will highlight those parts of the file containing the search string.

xcache php.ini

The screenshot confirms that xcache has been installed properly as expected and is now caching your PHP opcode behind the scenes to make your site even faster.

Leave a Reply

This Website is Hosted by

Powered by RamNode

Disclosure: We receive a compensation from some of the companies whose products or services are presented on our website.