Memcache not available for local cache

Nextcloud 18.0.3
OS Ubuntu 18.04
mariadb version
MariaDB [(none)]> select @@version as version;
±-------------------------------------------+
| version |
±-------------------------------------------+
| 10.3.22-MariaDB-1:10.3.22+maria~bionic-log
nginx version: nginx/1.16.1
php version 7.4

issue:
log file is filled every 5 mins with:
“user”:"–",“app”:“cli”,“method”:"",“url”:"–",“message”:“Memcache \OC\Memcache\APCu not available for local cache”,“userAgent”:"–",“version”:“18.0.3.0”}

The output of your config.php file in `/usr/share/nginx/nextcloud/config/config.php (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'oc95enutecg7',
  'passwordsalt' => 'zxhlweodhogedg/xxxxxxGTG',
  'secret' => 'lidleofnegasl/odkeoet34455ldfoewc',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'nextcloud',
    2 => '10.10.10.10',
    3 => 'myserver.com',
  ),
  'datadirectory' => '/mount1/nextcloud/data',
  'overwrite.cli.url' => 'https://myserver.com/',
  'dbtype' => 'mysql',
  'version' => '18.0.3.0',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'user_for_maria',
  'dbpassword' => 'password_for_db',
  'installed' => true,
  'memcache.local' => '\OC\Memcache\APCu',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'maintenance' => false,
  'theme' => '',
  'log_type' => 'file',
  'logfile' => '/mount1/nextcloud/data/nextcloud.log',
  'logdateformat' => 'F d, Y H:i:s',
  'logtimezone' => 'America/New_York',
  'log_rotate_size' => 104857600,
  'loglevel' => 1,
  'mail_smtpsecure' => 'tls',
  'mail_smtpauth' => 1,
  'mail_from_address' => 'my-mail',
  'mail_domain' => 'gmail.com',
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '587',
  'mail_smtpname' => 'my.email@gmail.com',
  'mail_smtppassword' => 'password_for_it',
  'trusted_proxies' =>
  array (
    0 => '192.168.1.254',
  ),
  'overwritehost' => 'myserver.com',
  'overwriteprotocol' => 'https',
  'overwritewebroot' => '',
  'updater.release.channel' => 'stable',
  'app_install_overwrite' =>
  array (
    0 => 'apporder',
    1 => 'ocsms',
  ),
  'simpleSignUpLink.shown' => false,
  'has_rebuilt_cache' => true,
  'mail_sendmailmode' => 'smtp',
);

Ran
/etc/php/7.4/fpm$ php -a
Interactive mode enabled

php > var_dump(ini_get(‘apc.enable_cli’));
string(1) “0”

Then ran:
php > phpinfo(INFO_MODULES);
phpinfo()

apc

APC Compatibility => 1.0.5

apcu

APCu Support => Disabled
Version => 5.1.18
APCu Debugging => Disabled
MMAP Support => Enabled
MMAP File Mask =>
Serialization Support => Disabled
Build Date => Dec 19 2019 10:45:24

after putting apc.enable_cli=1 in php.ini on this path; /etc/php/7.4/cli/php.ini

I now see APCu Support is enabled as the output shows below:

php > phpinfo(INFO_MODULES);
phpinfo()

apc

APC Compatibility => 1.0.5

apcu

APCu Support => Enabled
Version => 5.1.18
APCu Debugging => Disabled
MMAP Support => Enabled
MMAP File Mask =>
Serialization Support => php
Build Date => Dec 19 2019 10:45:24

Restarted nginx and php. Rebooted the server, still the log file gets new entries every 5 mins with
message":“Memcache \OC\Memcache\APCu not available for local cache”

Any idea how to resolve this? I do not have any other warnings on admin settings page.

Thanks in advance.

This is not a Nextcloud problem, but a problem of your web server/php environment. To prevent such a message you need to install and configure the missing php module. Please use the search function of the forum or ask aunt G. to get a more detailed answer on how this need to be done on your server.

Well, j-ed, for your information nextcloud’s heart is php and webserver, so you cannot say this is not a nextcloud issue. So when you take your car for service and the dealer tells you, sorry you got a broken transmission, but not necessarily this is a car issue, your car is fine and its engine runs great. How would you like that answer?

There are so many conflicting information at aunt.G and have tried too many of them but no go.

As far as php modules here is what I have installed.

$ apt list --installed | grep “php7.4”

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libapache2-mod-php7.4/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.4/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 all [installed,automatic]
php7.4-bz2/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed]
php7.4-cli/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.4-common/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.4-curl/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.4-fpm/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed]
php7.4-gd/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed]
php7.4-intl/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed]
php7.4-json/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.4-mbstring/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed]
php7.4-mysql/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed]
php7.4-opcache/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.4-readline/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.4-xml/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed]
php7.4-zip/bionic,now 7.4.4-1+ubuntu18.04.1+deb.sury.org+1 amd64 [installed]

Also here is the list of php modules in the server:

$ php7.4 -m
[PHP Modules]
apc
apcu
bz2
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
hash
iconv
imagick
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

Is there another module I’m missing?

Also there are so many .ini files related to php and this makes it easy to make mistakes

$ php --ini
Configuration File (php.ini) Path: /etc/php/7.4/cli
Loaded Configuration File: /etc/php/7.4/cli/php.ini
Scan for additional .ini files in: /etc/php/7.4/cli/conf.d
Additional .ini files parsed: /etc/php/7.4/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.4/cli/conf.d/10-opcache.ini,
/etc/php/7.4/cli/conf.d/10-pdo.ini,
/etc/php/7.4/cli/conf.d/15-xml.ini,
/etc/php/7.4/cli/conf.d/20-apcu.ini,
/etc/php/7.4/cli/conf.d/20-bz2.ini,
/etc/php/7.4/cli/conf.d/20-calendar.ini,
/etc/php/7.4/cli/conf.d/20-ctype.ini,
/etc/php/7.4/cli/conf.d/20-curl.ini,
/etc/php/7.4/cli/conf.d/20-dom.ini,
/etc/php/7.4/cli/conf.d/20-exif.ini,
/etc/php/7.4/cli/conf.d/20-ffi.ini,
/etc/php/7.4/cli/conf.d/20-fileinfo.ini,
/etc/php/7.4/cli/conf.d/20-ftp.ini,
/etc/php/7.4/cli/conf.d/20-gd.ini,
/etc/php/7.4/cli/conf.d/20-gettext.ini,
/etc/php/7.4/cli/conf.d/20-iconv.ini,
/etc/php/7.4/cli/conf.d/20-imagick.ini,
/etc/php/7.4/cli/conf.d/20-intl.ini,
/etc/php/7.4/cli/conf.d/20-json.ini,
/etc/php/7.4/cli/conf.d/20-mbstring.ini,
/etc/php/7.4/cli/conf.d/20-mysqli.ini,
/etc/php/7.4/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.4/cli/conf.d/20-phar.ini,
/etc/php/7.4/cli/conf.d/20-posix.ini,
/etc/php/7.4/cli/conf.d/20-readline.ini,
/etc/php/7.4/cli/conf.d/20-shmop.ini,
/etc/php/7.4/cli/conf.d/20-simplexml.ini,
/etc/php/7.4/cli/conf.d/20-sockets.ini,
/etc/php/7.4/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.4/cli/conf.d/20-sysvsem.ini,
/etc/php/7.4/cli/conf.d/20-sysvshm.ini,
/etc/php/7.4/cli/conf.d/20-tokenizer.ini,
/etc/php/7.4/cli/conf.d/20-xmlreader.ini,
/etc/php/7.4/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.4/cli/conf.d/20-xsl.ini,
/etc/php/7.4/cli/conf.d/20-zip.ini,
/etc/php/7.4/cli/conf.d/25-apcu_bc.ini

Anyone else can assist on this?

Thanks,

I would say, you cannot blame the company who build the car, if the street you are driving on is broken. A specific PHP configuration setup, outsite of Nextcloud, is required to use the software. :wink:

As many other users, you seem not to differentiate between the PHP CLI and the PHP WEB component. You have to make sure that the modules are installed, configured and loaded for both components.
For the PHP CLI component, you have to run php -m to get a list of loaded modules displayed.
For the PHP WEB component you have to create a PHP file containing “<?php phpinfo() ?>” and open it using a web browser to list of loaded modules displayed. (keep in mind to delete the file after you’ve solved your issue.).

Thanks for your reply. I do not have any warnings for cache in the admin page and the entry in the log clearly says that it is in the CLI component, hence I was focused on php-cli module.

app”:“cli”,“method”:"",“url”:"–",“message”:“Memcache \OC\Memcache\APCu not available for local cache”,“userAgent”:"–",“version”:“18.0.3.0”}

Nextcloud doc also states this https://docs.nextcloud.com/server/18/admin_manual/configuration_server/caching_configuration.html#id1

Warning

APCu is disabled by default on CLI which could cause issues with nextcloud’s cron jobs. Please make sure you set the apc.enable_cli to 1 on your php.ini config file.

Is there a specific place, section of the php.ini where this entry goes? I placed it in the bottom of the file as did not find any traces of a disabled entry of it in the file.

You think the issue is in the PHP WEB?

Thanks,

Sorry, my fault. I haven’t seen the “cli” in that log line. In my server the APCu specific configuration can be found in an apcu.ini file

apcu.ini:extension=apcu.so
apcu.ini:apc.enabled=1
apcu.ini:apc.enable_cli=1
1 Like

That is what I tried first. For me (ubuntu 18.04 LTS) that apcu.ini file is in this path:
/etc/php/7.4/mods-available$

Putting the entry apc.enable_cli=1 in this file and reloading php and restarting nginx did not make a difference. Entries still show up in the nextcloud.log file.

The doc from nextcloud though(the link I gave above) does not advise you to put the entry in the apcu.ini file but in php.ini file which is not the same.

Like I said, there are lots of conflicting info out there.

I also see this other line for "distributed cache:

time":“April 08, 2020 12:35:01”,“remoteAddr”:"",“user”:"–",“app”:“cli”,“method”:"",“url”:"–",“message”:“Memcache \OC\Memcache\APCu not available for local cache”,“userAgent”:"–",“version”:“18.0.3.0”}

“level”:1,“time”:“April 08, 2020 12:35:01”,“remoteAddr”:"",“user”:"–",“app”:“cli”,“method”:"",“url”:"–",“message”:“Memcache \OC\Memcache\APCu not available for distributed cache”,“userAgent”:"–",“version”:“18.0.3.0”}

They always show together in the log file every 5 mins.

I don’t have redis installed and configured as i thought that was optional especially for a single server for home usage. My whole setup is a VM that sits on a SSD storage.

Therefore I don’t have entry on config.php for distributed cache.

Question: Why the entries in the log file show with \ (double back slashes) ? Maybe that’s why some directions have the entry in the config.php file with \ for Memcache like so?

'memcache.local' => '\\OC\\Memcache\\APCu',  

Which I think is wrong.  

I'm still stuck on this and don't know where the issue is. 

Thanks for your reply anyway.

Did yo installed PHP module memcache or PHP module memcached? PHP module memcached is the right module.

I see that message for a while. Guess it’s a bug.

Installed memcached via sudo apt-get install -y php7.4-memcached

I now see that memcached is enabled

php -a
Interactive mode enabled

php > var_dump(ini_get(‘apc.enable_cli’));
string(1) “1”
php > phpinfo(INFO_MODULES);

memcached

memcached support => enabled
Version => 3.1.4
libmemcached version => 1.0.18
SASL support => yes
Session support => yes
igbinary support => yes
json support => yes
msgpack support => yes

Directive => Local Value => Master Value
memcached.compression_factor => 1.3 => 1.3
memcached.compression_threshold => 2000 => 2000
memcached.compression_type => fastlz => fastlz
memcached.default_binary_protocol => Off => Off
memcached.default_connect_timeout => 0 => 0
memcached.default_consistent_hash => Off => Off
memcached.serializer => php => php
memcached.sess_binary_protocol => On => On
memcached.sess_connect_timeout => 0 => 0
memcached.sess_consistent_hash => On => On
memcached.sess_consistent_hash_type => ketama => ketama
memcached.sess_lock_expire => 0 => 0
memcached.sess_lock_max_wait => not set => not set
memcached.sess_lock_retries => 5 => 5
memcached.sess_lock_wait => not set => not set
memcached.sess_lock_wait_max => 150 => 150
memcached.sess_lock_wait_min => 150 => 150
memcached.sess_locking => On => On
memcached.sess_number_of_replicas => 0 => 0
memcached.sess_persistent => Off => Off
memcached.sess_prefix => memc.sess.key. => memc.sess.key.
memcached.sess_randomize_replica_read => Off => Off
memcached.sess_remove_failed_servers => Off => Off
memcached.sess_sasl_password => no value => no value
memcached.sess_sasl_username => no value => no value
memcached.sess_server_failure_limit => 0 => 0
memcached.store_retry_count => 2 => 2

I also see this new file created /etc/php/7.4/mods-available/memcached.ini
also both symlinks are created in CLI and FPM directories:

/etc/php/7.4/cli/conf.d$ ls -l
total 0
lrwxrwxrwx 1 root root 39 Mar 29 13:12 10-mysqlnd.ini -> /etc/php/7.4/mods-available/mysqlnd.ini
lrwxrwxrwx 1 root root 39 Dec 26 01:50 10-opcache.ini -> /etc/php/7.4/mods-available/opcache.ini
lrwxrwxrwx 1 root root 35 Dec 26 01:50 10-pdo.ini -> /etc/php/7.4/mods-available/pdo.ini
lrwxrwxrwx 1 root root 35 Mar 29 13:11 15-xml.ini -> /etc/php/7.4/mods-available/xml.ini
lrwxrwxrwx 1 root root 36 Dec 26 01:52 20-apcu.ini -> /etc/php/7.4/mods-available/apcu.ini
lrwxrwxrwx 1 root root 35 Mar 29 13:14 20-bz2.ini -> /etc/php/7.4/mods-available/bz2.ini
lrwxrwxrwx 1 root root 40 Dec 26 01:50 20-calendar.ini -> /etc/php/7.4/mods-available/calendar.ini
lrwxrwxrwx 1 root root 37 Dec 26 01:50 20-ctype.ini -> /etc/php/7.4/mods-available/ctype.ini
lrwxrwxrwx 1 root root 36 Dec 26 01:51 20-curl.ini -> /etc/php/7.4/mods-available/curl.ini
lrwxrwxrwx 1 root root 35 Mar 29 13:11 20-dom.ini -> /etc/php/7.4/mods-available/dom.ini
lrwxrwxrwx 1 root root 36 Dec 26 01:50 20-exif.ini -> /etc/php/7.4/mods-available/exif.ini
lrwxrwxrwx 1 root root 35 Dec 26 01:50 20-ffi.ini -> /etc/php/7.4/mods-available/ffi.ini
lrwxrwxrwx 1 root root 40 Dec 26 01:50 20-fileinfo.ini -> /etc/php/7.4/mods-available/fileinfo.ini
lrwxrwxrwx 1 root root 35 Dec 26 01:50 20-ftp.ini -> /etc/php/7.4/mods-available/ftp.ini
lrwxrwxrwx 1 root root 34 Mar 29 13:11 20-gd.ini -> /etc/php/7.4/mods-available/gd.ini
lrwxrwxrwx 1 root root 39 Dec 26 01:50 20-gettext.ini -> /etc/php/7.4/mods-available/gettext.ini
lrwxrwxrwx 1 root root 37 Dec 26 01:50 20-iconv.ini -> /etc/php/7.4/mods-available/iconv.ini
lrwxrwxrwx 1 root root 40 Apr 8 20:33 20-igbinary.ini -> /etc/php/7.4/mods-available/igbinary.ini
lrwxrwxrwx 1 root root 39 Mar 4 23:21 20-imagick.ini -> /etc/php/7.4/mods-available/imagick.ini
lrwxrwxrwx 1 root root 36 Mar 29 13:14 20-intl.ini -> /etc/php/7.4/mods-available/intl.ini
lrwxrwxrwx 1 root root 36 Dec 26 01:51 20-json.ini -> /etc/php/7.4/mods-available/json.ini
lrwxrwxrwx 1 root root 40 Mar 29 13:17 20-mbstring.ini -> /etc/php/7.4/mods-available/mbstring.ini
lrwxrwxrwx 1 root root 39 Apr 8 20:33 20-msgpack.ini -> /etc/php/7.4/mods-available/msgpack.ini
lrwxrwxrwx 1 root root 38 Mar 29 13:12 20-mysqli.ini -> /etc/php/7.4/mods-available/mysqli.ini
lrwxrwxrwx 1 root root 41 Mar 29 13:12 20-pdo_mysql.ini -> /etc/php/7.4/mods-available/pdo_mysql.ini
lrwxrwxrwx 1 root root 36 Dec 26 01:50 20-phar.ini -> /etc/php/7.4/mods-available/phar.ini
lrwxrwxrwx 1 root root 37 Dec 26 01:50 20-posix.ini -> /etc/php/7.4/mods-available/posix.ini
lrwxrwxrwx 1 root root 40 Dec 26 01:51 20-readline.ini -> /etc/php/7.4/mods-available/readline.ini
lrwxrwxrwx 1 root root 37 Dec 26 01:50 20-shmop.ini -> /etc/php/7.4/mods-available/shmop.ini
lrwxrwxrwx 1 root root 41 Mar 29 13:11 20-simplexml.ini -> /etc/php/7.4/mods-available/simplexml.ini
lrwxrwxrwx 1 root root 39 Dec 26 01:50 20-sockets.ini -> /etc/php/7.4/mods-available/sockets.ini
lrwxrwxrwx 1 root root 39 Dec 26 01:50 20-sysvmsg.ini -> /etc/php/7.4/mods-available/sysvmsg.ini
lrwxrwxrwx 1 root root 39 Dec 26 01:50 20-sysvsem.ini -> /etc/php/7.4/mods-available/sysvsem.ini
lrwxrwxrwx 1 root root 39 Dec 26 01:50 20-sysvshm.ini -> /etc/php/7.4/mods-available/sysvshm.ini
lrwxrwxrwx 1 root root 41 Dec 26 01:50 20-tokenizer.ini -> /etc/php/7.4/mods-available/tokenizer.ini
lrwxrwxrwx 1 root root 41 Mar 29 13:11 20-xmlreader.ini -> /etc/php/7.4/mods-available/xmlreader.ini
lrwxrwxrwx 1 root root 41 Mar 29 13:11 20-xmlwriter.ini -> /etc/php/7.4/mods-available/xmlwriter.ini
lrwxrwxrwx 1 root root 35 Mar 29 13:11 20-xsl.ini -> /etc/php/7.4/mods-available/xsl.ini
lrwxrwxrwx 1 root root 35 Mar 29 13:13 20-zip.ini -> /etc/php/7.4/mods-available/zip.ini
lrwxrwxrwx 1 root root 39 Dec 26 01:51 25-apcu_bc.ini -> /etc/php/7.4/mods-available/apcu_bc.ini
lrwxrwxrwx 1 root root 41 Apr 8 20:33 25-memcached.ini -> /etc/php/7.4/mods-available/memcached.ini

rebooted the server.

Still the annoying entries show in the log as below

“level”:1,“time”:“April 08, 2020 21:20:02”,“remoteAddr”:"",“user”:"–",“app”:“cli”,“method”:"",“url”:"–",“message”:“Memcache \OC\Memcache\APCu not available for local cache”,“userAgent”:"–",“version”:“18.0.3.0”}

“level”:1,“time”:“April 08, 2020 21:20:02”,“remoteAddr”:"",“user”:"–",“app”:“cli”,“method”:"",“url”:"–",“message”:“Memcache \OC\Memcache\APCu not available for distributed cache”,“userAgent”:"–",“version”:“18.0.3.0”}

maybe I need to install memcache as the log file indicates and not memcached ?
Do I have to put any entires in the memcached.ini files for CLI and FPM modules?

Still stuck on this.

Sorry, this reply is for @u_n_glaublich

Why should it help to install Memcache/Memcached if the message states that "APCu is not available for local cache"?! The available memory cache options are explained in detail here.

I thought you said initially this comes from a missing php module. It made sense to try it as memcached is also recommended from Nextcloud doc for distributed caching but apparently is not working. I can chose to ignore this as everything else works fine but is impacting the log file as it makes difficult to read it for other info in there and of course causes unnecessary rotations of this log. Nextcloud docs ususally are very detailed for other things but they look gray on this topic. If they recommend to deploy memory caching they should provide steps on how to install and configure it… I still don’t understand why the php web is not complaining and I have no warnings on admin page under setting–>overview.

Will keep looking for solutions,

Due to the fact that the messages seem to be generated by the php cli component, which is primarily been used by the cron script, you should make sure that this also uses the correct php7.4 interpreter. If it uses a different one, which might be installed on your server in parallel and not being configured, the problem could be caused by it.

fcrontab -l <web-server-user> | grep "cron.php"

Thank you j-ed!!! That was it. I had this line in the cron job.

m h dom mon dow command

*/5 * * * * php7.2 -f /usr/share/nginx/nextcloud/cron.php > /dev/null 2>&1

Apparently was using php7.2 in the cron. Updated it with 7.4 in the path and now the entries stopped in the log file. Wow… Thanks for pointing that out.

1 Like