Check if opcache is enabled and how can it help my site

Check if opcache is enabled and how can it help my site

Following on from the article in which we dealt with the subject of cache memory, also known as cache memory, today we will expand on another type of cache memory on the part of the site’s hosting / storage server.

Check if opcache is enabled and how can it help my site

Before we try to explain what OPCACHE is and how it can help my site, we need to have an initial understanding of some basic concepts in understanding the activity of the site in front of the server, right at the tip of the fork. Websites in principle (and let’s put aside the matter of the DNS system redirection now is already a topic for a whole lesson) are basically a system of real, large-volume folders, files and database that are on a physical server (maybe even a virtual server or some cloud solution, but in the end Of day there is an actual box that holds the virtualization of things that functions just like the computer in your home) across the network. The surfers reach the server that “holds” the site through their browser. The server can come in a variety of platforms and configurations with diverse specifications on the hardware and software side.

The main division

The main division is between microsoft servers and linux servers (the latter are considered more common in the field of web servers in the world). The web server is basically a large and powerful type of computer that runs a number of systems and services. The basic services in the context of the basic activity of the site are: the web-server service, the database service – mysql / sql and the PHP service which is the code language on the part of the server which is largely responsible for mediating the activity between the site system and other services on the server. From the site system to the database. The WordPress system cannot speak directly to the database and therefore it uses PHP – the server language to perform the above operations). The server-side code (back-end) does not necessarily have to be in the PHP language but in most cases on linux servers the working method is configured as a lamp. Okay, so we pretty much figured out who’s up against whom and what’s going on behind the scenes on our cute little WordPress site. We can now understand that OPcache activity is designed to optimize PHP performance by keeping temporary memory on the server in the order of operations required for site performance and activity. For the purpose of illustration, a surfer named David asked to come to the contact page on our site. The PHP on the server had to perform a number of calculations and actions related to this particular request versus a number of components on the server. David gets the contact page he requested while the OPcache will now remember on the side all the actions required to perform when the next surfer (Shlomo) will also request the above contact page. Although this is an incomplete and inefficient cache solution such as using a dedicated plugin in the site system, it is an important tool that in many cases gives a significant improvement (both in terms of the speed of site operation and in terms of reducing server load).

Setting up OPCACHE in the cPanel interface

OPcache is active from PHP5.5 and above. It can be configured independently through the cPanel interface under: Select PHP Version category. We will make sure that opcache is active and if it is not necessary to mark and confirm in set as current:

Setting up OPCACHE on a LiteSpeed ​​server

First of all, we will check the active PHP version of the site in question. We will use a basic test file – phpinfo and access it from the browser at the appropriate URL. Once we know which version of PHP it is, we go to the command interface (shell) on the storage server and check if the Opcache component is installed for the relevant PHP, for example for PHP 7 Run: # yum list lsphp70* And we will get the list of plugins installed under “Installed Packages” and the plugins available for download under “Available Packages” In our case, PHP 7 does not contain the opcache component: We will run the installation command (specifically in our case): # yum install lsphp70-opcache.x86_64 We will confirm the confirmation message with the “y” relief: And we will make sure to complete the process in “Complete!”: That is, now there is the Opcache in PHP 7 (if there are additional PHP versions on the server, the test / installation procedure must be performed against each version separately)