[Solved] Activate APCu for CLI on HestiaCP

Hello :wink:

I try to install and activate APCu on HestiaCP (on a Ubuntu 20.04 LTS)

# dpkg -l *apcu* | grep ii
ii  php-apcu       5.1.21+4.0.11-8+ubuntu20.04.1+deb.sury.org+1 amd64        APC User Cache for PHP
ii  php7.0-apcu    5.1.21+4.0.11-8+ubuntu20.04.1+deb.sury.org+1 amd64        APC User Cache for PHP
ii  php7.1-apcu    5.1.21+4.0.11-8+ubuntu20.04.1+deb.sury.org+1 amd64        APC User Cache for PHP
ii  php7.2-apcu    5.1.21+4.0.11-8+ubuntu20.04.1+deb.sury.org+1 amd64        APC User Cache for PHP
ii  php7.3-apcu    5.1.21+4.0.11-8+ubuntu20.04.1+deb.sury.org+1 amd64        APC User Cache for PHP
ii  php7.4-apcu    5.1.21+4.0.11-8+ubuntu20.04.1+deb.sury.org+1 amd64        APC User Cache for PHP
ii  php8.0-apcu    5.1.21+4.0.11-8+ubuntu20.04.1+deb.sury.org+1 amd64        APC User Cache for PHP
ii  php8.1-apcu    5.1.21+4.0.11-8+ubuntu20.04.1+deb.sury.org+1 amd64        APC User Cache for PHP

# php -m
[PHP Modules]
apcu
bcmath
bz2
calendar
Core
[…]

# systemctl restart apache2

$ drush cr
PHP Fatal error:  Uncaught Error: APC must be enabled to use APCUIterator in /home/floown/web/mydomain.com/public_html/web/core/lib/Drupal/Core/Cache/ApcuBackend.php:270
Stack trace:
#0 /home/floown/web/mydomain.com/public_html/web/core/lib/Drupal/Core/Cache/ApcuBackend.php(270): APCUIterator->__construct()
#1 /home/floown/web/mydomain.com/public_html/web/core/lib/Drupal/Core/Cache/ApcuBackend.php(209): Drupal\Core\Cache\ApcuBackend->getIterator()
[…]
 [warning] Drush command terminated abnormally.

If have seen this response for Docker: https://stackoverflow.com/questions/64499004/apcu-is-not-enabled-cant-create-fixtures

What file should I edit to activate APCu on php 8.0 ?

Thanks

Ok, a simple vim /etc/php/8.0/cli/php.ini and add in bottom the file:
apc.enable_cli = 1

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.