How to Enable OPcache in cPanel

Posted on November 11th, 2016

What is OPcache

The OPcache is a PHP extension. This extension is a good solution to the performance issues of your website. OPcache improves the PHP performance by storing compiled script byte code in shared memory. Thus, it removes the need for PHP to load and parse scripts on each request. This feature affects the performance positively. It brings the loading time of the website down by increasing the processing speed of the request by the webserver. To an extent, OPcache also helps to avoid load on the server. The OPcache is bundled with PHP from the PHP 5.5.0 and later. OPcache is also available in PECL. In short, the caching engine that comes with the PHP 5.5 is called the OPcache.


OPcache – Working

The OPcache works similar to APC, Xcache, etc. When looking into the working of OPcache, as we all know, each PHP script needs to be compiled at run time. This execution includes the transformation of text to binary. This will take some time. Even though this will be a smaller time, it will be considerable. Suppose that a single script is being called by 100 users, then this time will be 100 times more than that of the case where a single user is called. It can also increase the load of your webserver acting with other tasks also. This is a disadvantage for the PHP to implement this transfer. Here is where a caching engine will help you. As in the case of APC or Xcache, the caching engines will do it only once. This will be at the time of the first execution of a specific PHP file. The OPcache also works in the same way. After the first execution, the precompiled script is being stored in the memory. This precompiled script can be used for the next time. This will make a considerable performance boost in your PHP based web applications.


Why should you install OPcache

If you have hosted your website in a shared server that received small amount of request and runs at a good speed, you might not have worried about the performance till now. But, if you are on a server that has too much traffic or you are running a website that will receive high traffic, it’s the time to think about a caching engine. The built-in caching engine in PHP will meet your performance needs up to an extent. You can use the OPcache if you are expecting more traffic with your websites in the future.


Enabling OPcache

You can enable the OPcache easily with the cPanel Interface. Follow the below steps to enable the OPcache for your website.

1) Login to the cPanel Interface.

2) Go to the ‘Select PHP Version’ under the section ‘Software’. A page of PHP Selector | extensions will be opened.



3) Look for the ‘Current PHP version’. If it is native, please change it to some other version. You could keep the version same without the native option.

4) Check the checkbox near to the ‘opcache’.



5) Click on the button ‘Save’.

6) You have successfully installed the OPcache extension now.


If you need any further assistance please contact our support department.



2 Responses to “How to Enable OPcache in cPanel”

  1. chanda charles says:

    Thanks alot. this information saved me. Very helpful

Leave a Reply