How to install Zend OPcache in DirectAdmin

What is Zend OPcache?

Zend OPcache, developed by Zend.com, is an Apache module designed to accelerate web sites speed. It uses caching and optimization techniques. The caching is archived by storing pre-compiled PHP code in the shared memory of the server. The description from the PHP.net website is:

OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.

https://www.php.net/manual/en/intro.opcache.php

For more information, please check the PHP OPcache page at https://www.php.net/manual/en/book.opcache.php

zend opcache
OPcache page

How to install PHP OPcache extension on a Directadmin server:

1. Log in to the server with SSH as an admin

2. Check if the module is installed or not. There are two commands you can use:

php -v
php -m | grep OPcache

If the commands do not return a result, it means the module is not installed.

3. Navigate to the CustomBuild directory

cd /usr/local/directadmin/custombuild

4. Set the OPcache value to YES:

./build set opcache yes
[root@web custombuild]# ./build set opcache yes
Changed opcache option from no to yes
[root@web custombuild]#

5. Build the OPcache module:

./build opcache
[root@web custombuild]# ./build opcache
opCache is now installed for PHP 7.4.
opCache is now installed for PHP 7.3.

There is no ionCube loader available for PHP 8.0.
opCache is now installed for PHP 8.0.
Restarting php-fpm74.
Restarting php-fpm73.

Restarting php-fpm80.
[root@web custombuild]#

6. Verify it by:

[root@web ~]# php -m | grep OPcache
Zend OPcache

Zend OPcache
[root@web ~]#

or

[root@web custombuild]# php -v
PHP 7.4.21 (cli) (built: Jul  2 2021 07:15:23) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with the ionCube PHP Loader + ionCube24 v10.4.5, Copyright (c) 2002-2020, by ionCube Ltd.
    with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies
[root@web custombuild]#

Links:
OPcache configuration options

Leave a Reply