Server has the Apcu extension but php Apcu php error

server has the Apcu extension running.
There is no problem using the apcu at all.
However, when I run php from the command line, an error occurs.

Tygh\Exceptions\ClassNotFoundException: “APCu” PHP extension is not installed.
in /app/Tygh/Backend/Cache/Apcu.php:36
/app/Tygh/Registry.php(384): Tygh\Backend\Cache\Apcu->__construct()
Stack trace:
#0 app/Tygh/Registry.php(384): Tygh\Backend\Cache\Apcu->__construct()
#1 /app/Tygh/Registry.php(312): Tygh\Registry::cacheInit()
#2 /app/Tygh/Registry.php(797): Tygh\Registry::registerCache()
#3 /app/functions/fn.init.php(1155): Tygh\Registry::getOrSetCache()
#4 /app/functions/fn.init.php(1227): fn_init_unmanaged_addons()
#5 init.php(195): fn_init()
Tygh\Exceptions\AException

Message
“APCu” PHP extension is not installed.

Error at
app/Tygh/Backend/Cache/Apcu.php, line: 36

Backtrace
File:app/Tygh/Registry.php
Line:384
Function:__construct

File:app/Tygh/Registry.php
Line:312
Function:cacheInit

File:app/Tygh/Registry.php
Line:797
Function:registerCache

File:app/functions/fn.init.php
Line:1155
Function:getOrSetCache

File:app/functions/fn.init.php
Line:1227
Function:fn_init_unmanaged_addons

File:init.php
Line:195
Function:fn_init

File:admin.php
Line:19
Function:require

Does anyone know why this happens?

Hi,

Try to restart apache2 or http server and refresh requirements. it will pass the requirements.

Thanks

CLI (command line interface) and web server can use different PHP versions installed at the server with different PHP extensions installed. Make sure that the version of PHP used by CLI has APCu extension installed.

You can check what version is used in CLI via the following command:

php -v

Then you can install the necessary PHP extensions for this specific version.

Thank you for answer.
I restarted nginx, but the error remains.

hi.
Thank you for answer.
If do php -v
Zend Engine v4.2.15, Copyright (c) Zend Technologies
with Zend OPcache v8.2.15, Copyright (c), by Zend Technologies

It comes out just like this.

I am using php 7.4 and apcu is checked in phpinfo and backend cache using apcu
Is the problem with the way I installed the apcu?

Hi,

In another case ,

try to run :
sudo apt install php-apcu && sudo apt install php7.4-apcu

restart nginx and fpm server

Thanks

Hi Thank you for reply
that command error occur.
E: Unable to locate package php7.4-apcu
E: Couldn’t find any package by glob ‘php7.4-apcu’
When installing php-apcu, it is only installed on php8.1, so I installed it manually.
Would this be a problem?

Hi,

no, that wont be a problem.

The latest cscart version support php8.1 and you can change current php version using this update-alternatives --config php . choose php8.1 and then fpm sock also change to php8.1
restart nginx and fpm server.
In other cases you can use php8.0 still support for cscart platform and all the changes mentioned earlier.
Thanks

1 Like

Thanks to you, I think it has been resolved.
I thought about upgrading the version, but once I tried it, it worked.
thank you :slight_smile: