OPcache is a caching engine built into PHP, which can significantly improve website performance by storing precompiled PHP script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.
On VPS and Dedicated servers, this is usually already installed, but there are some situations where it may not be, such as when a new PHP version is installed. Here we cover how to check if OPcache is installed and how to enable it on your VPS or Dedicated server through your Root WHM or via command line.
Related Articles
How to SSH into VPS or Dedicated Servers
Provision EasyApache 4 Changes
Install PHP Versions on VPS and Dedicated Servers
Create phpinfo Page
Check if OPcache is Installed via Command Line
- Access the server via SSH or by using the Terminal in cPanel or Root WHM
- Run the following command:
/opt/cpanel/ea-php##/root/usr/bin/php -m | grep OPcache
REPLACE: "##" with the PHP version number minus the "."
EXAMPLE: if your site is using PHP 7.4:/opt/cpanel/ea-php74/root/usr/bin/php -m | grep OPcache
- If installed, results should appear like the following
userna5@domain.com [~]# /opt/cpanel/ea-php74/root/usr/bin/php -m |grep OPcache
Zend OPcache
Zend OPcache
Check if OPcache is Installed Using phpinfo Page
- Create a phpinfo page and navigate to it in your browser
- If installed, it will be shown in the Zend Engine section
Install through WHM
IMPORTANT: This solution will require root access. If this needs to be obtained, follow the guide on requesting root access.
- Log into Root WHM
- Navigate to Software -> EasyApache 4
- Click the Customize button in the Currently Installed Packages section
- Select PHP Extensions
- Type "opcache" into the search box
- Click the toggle button to the right of the PHP version(s) you'd like to install OPcache for so that it turns blue and the word "Install" appears
- Select Review
- Scroll to the bottom of the page and click on the Provision button
- Wait for the provisioning process to complete
Install via Command Line
IMPORTANT: This solution will require root access. If this needs to be obtained, follow the guide on requesting root access.
NOTE: This is an alternative to the above solution and is not required if you've already completed the previous steps.
- Access the server via SSH as the root user or using the Terminal in your Root WHM
- Run the following command to search for the specific package to install:
yum search opcache
- Locate the appropriate package based on the PHP version your site is using
- Run the following command to install the package
yum -y install package_name
REPLACE: "package_name" with the name of the package determined in the previous step.
EXAMPLE:
yum -y install ea-php74-php-opcache.x86_64
- Wait for the installation to complete
Comments
0 comments
Please sign in to leave a comment.