\OC\Memcache\APCu not available for local cache (issue upon initial setup)

Nextcloud 24.0.1
Ubuntu 22.04 LTS
Apache2 / MySQL
PHP Version 8.0

Config.php file:

<?php
$CONFIG = array (
  'instanceid' => 'ocqkh37jzrid',
  'passwordsalt' => '27ZqiQEJcutckx4gApE2mgIRc/CEBV',
  'secret' => '0/fD8onLt5mm1YGiB3ZqSrp0AynN8VbqCNaT3nQqilZuBz7M',
  'trusted_domains' =>
  array (
    0 => '10.0.0.32',
    1 => '192.168.1.77',
    2 => 'my.domain.com',
  ),
  'datadirectory' => '/mnt/nxtcld-md0-raid1/data',
  'dbtype' => 'mysql',
  'default_phone_region' => 'US',
  'version' => '24.0.1.1',
  'overwrite.cli.url' => 'https://my.domain.com',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'dbpassword',
  'installed' => true,
  'filelocking.enabled' => true,
  'memcache.local' => '\OC\Memcache\APCu',
  'memcache.locking' => '\OC\Memcache\Redis',
  'redis' =>
  array (
    'host' => '127.0.0.1',
    'port' => 6379,
  ),
);

I’m trying to restore my files from a previous Nextcloud instance (which has worked before) using this command:

sudo -u www-data php /var/www/nextcloud/occ files:scan --all

However, no matter what solution I implement, I get this error most of the time:

OCP\HintException: [0]: Memcache \OC\Memcache\APCu not available for local cache (Is the matching PHP module installed and enabled?)

I try to run the following code that many say fixes the problem, but I get all of this in response:

sudo -u www-data php --define apc.enable_cli=1  /var/www/nextcloud/occ  maintenance:repair
An unhandled exception has been thrown:
Error: Call to undefined function simplexml_load_file() in /var/www/nextcloud/lib/private/App/InfoParser.php:69
Stack trace:
#0 /var/www/nextcloud/lib/private/App/AppManager.php(506): OC\App\InfoParser->parse()
#1 /var/www/nextcloud/lib/private/legacy/OC_App.php(595): OC\App\AppManager->getAppInfo()
#2 /var/www/nextcloud/lib/private/AppFramework/App.php(74): OC_App::getAppInfo()
#3 /var/www/nextcloud/lib/private/legacy/OC_App.php(280): OC\AppFramework\App::buildAppNamespace()
#4 /var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php(117): OC_App::registerAutoloading()
#5 /var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php(91): OC\AppFramework\Bootstrap\Coordinator->registerApps()
#6 /var/www/nextcloud/lib/base.php(654): OC\AppFramework\Bootstrap\Coordinator->runInitialRegistration()
#7 /var/www/nextcloud/lib/base.php(1104): OC::init()
#8 /var/www/nextcloud/console.php(48): require_once('...')
#9 /var/www/nextcloud/occ(11): require_once('...')

List of installed PHP modules:

[PHP Modules]
apcu
bcmath
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

I have php8.0-apcu installed, but maybe I need to install something else…? Ngl, I’m a bit of a novice to server maintenance (especially this), but I’m a moderate Ubuntu user. I’m more than willing to walk through anything I’ve already setup/installed/configured. Any advice or help is greatly appreciated.

I have the same issue with PHP8.0-apcu. Tried adding apc.enable_cli=1 to /etc/php/8.0/apache2/php.ini, /etc/php/8.0/cli/php.ini and /etc/php/8.0/mods-available/apcu.ini.

Even adding apc.shm_size=512M to /etc/php/8.0/mods-available/apcu.ini still no luck…

Some other posts suggest going to an earlier version of php, but I will wait for a solution for php8.0

Update (2 mins later):

sudo -u www-data php8.0 --define apc.enable_cli=1  /var/www/nextcloud/occ  maintenance:repair

Worked!

3 Likes

I actually tried it again using the latest PHP version (8.1) along with the latest version of NC (24.0.2) and it worked ok for me. I still had to add that one line in the cli/php.ini file. All good now!

2 Likes

Thanks a lot @bluestarzero

do you remember what line you had to add to cli/php.ini ?

1 Like

apc.enable_cli=1