'memcache.local' => '\OC\Memcache\APCu', not working in config.php

Here is the config.php file

<?php
$CONFIG = array (
  'instanceid' => 'ocu4bs5f5l77',
  'passwordsalt' => XXXXXX
  'secret' => XXXXXX
  'trusted_domains' => 
  array (
    0 => 'XXXXXXX',
    1 => 'XXXXXXXXX',
  ),
  'datadirectory' => '/var/nextcloud/data',
  'overwrite.cli.url' => 'myexample/nextcloud',
  'dbtype' => 'sqlite3',
  'version' => '12.0.2.0',
  'installed' => true,
  'mail_from_address' => 'xxxxxxxxx',
  'mail_smtpmode' => 'php',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_domain' => 'gmail.com', 
  # ‘memcache.local’ => ‘\OC\Memcache\APCu’,
  'memcache.local' => '\OC\Memcache\APCu',
);

Everything works great except for when I add the last line it. When I remove memcache.local everything works again. Thank You very much for the help. (I’m not sure what Happened with the formatting when it posted)

Check out the apostrophes you’re using. They’re not right.
I commented yours out and fixed it in the example above.

Thanks for clearing up the apostrophes. I replaced the whole last line with your suggestion. With the changes, I am still unable to log in to NextCloud, but removing the last line allows connection. I’m still getting

This page isn’t working

myexample.com/nextcloud is currently unable to handle this request.
HTTP ERROR 503

<?php
$CONFIG = array (
  'instanceid' => 'ocu4bs5f5l77',
  'passwordsalt' => '/XXXXXX',
  'secret' => 'iuD/XXXXXX',
  'trusted_domains' => 
  array (
    0 => 'XXX.XXX.XXX.XXX',
    1 => 'XXXXXX',
  ),
  'datadirectory' => '/var/nextcloud/data',
  'overwrite.cli.url' => 'http://XXX.XXX.XXX.XXX/nextcloud',
  'dbtype' => 'sqlite3',
  'version' => '12.0.2.0',
  'installed' => true,
  'mail_from_address' => 'XXXXXX',
  'mail_smtpmode' => 'php',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_domain' => 'gmail.com', 
  'memcache.local' => '\OC\Memcache\APCu',
);

I have read about enabling acpu and memcahed. I’m not sure how to check to see if it is enabled. This might be the issue. I did set apcu.enable_cli=1 in php.ini

Try escaping the backslash like this.

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

Shouldn’t be necessary.

Did you install ACPu?
sudo apt install php-apcu

Otherwise, open your Apache error.log and tell us what it says:

sudo less /var/log/apache2/error.log

2 Likes

Also check if the module is active by “php -m”. You should see the entry “apcu” there at/near the top.

apcu.enable_cli=1” is by the way wrong, it would be “apc.enable_cli=1” (without “u”): http://php.net/manual/en/apcu.configuration.php. It is anyway not necessary to set, but recommended to avoid annoying info entries in your nextcloud log :wink:. “apc.enabled=1” would be necessary to run Nextcloud with APCu configured, but as this is default, you don’t need to explicitly set it anywhere.

1 Like

Yes, I did sudo apt-get install php-apcu before. I also had “apc.enable_cli=1” and I just added apc.enabled=1 in /etc/php/7.0/mods-available/apcu.ini

sudo less /var/log/apache2/error.log

[Sun Sep 17 06:25:19.390215 2017] [ssl:warn] [pid 472] AH01906: 127.0.1.1:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sun Sep 17 06:25:19.390476 2017] [ssl:warn] [pid 472] AH01909: 127.0.1.1:443:0 server certificate does NOT include an ID which matches the server name
[Sun Sep 17 06:25:19.391347 2017] [mpm_prefork:notice] [pid 472] AH00163: Apache/2.4.25 (Raspbian) OpenSSL/1.0.2l configured – resuming normal operations
[Sun Sep 17 06:25:19.391403 2017] [core:notice] [pid 472] AH00094: Command line: ‘/usr/sbin/apache2’
[Sun Sep 17 11:17:54.602234 2017] [mpm_prefork:notice] [pid 472] AH00169: caught SIGTERM, shutting down
[Sun Sep 17 11:18:00.179661 2017] [ssl:warn] [pid 3825] AH01906: 127.0.1.1:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sun Sep 17 11:18:00.179903 2017] [ssl:warn] [pid 3825] AH01909: 127.0.1.1:443:0 server certificate does NOT include an ID which matches the server name[Sun Sep 17 11:18:00.645844 2017] [ssl:warn] [pid 3826] AH01906: 127.0.1.1:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sun Sep 17 11:18:00.646039 2017] [ssl:warn] [pid 3826] AH01909: 127.0.1.1:443:0 server certificate does NOT include an ID which matches the server name[Sun Sep 17 11:18:00.664599 2017] [mpm_prefork:notice] [pid 3826] AH00163: Apache/2.4.25 (Raspbian) OpenSSL/1.0.2l configured – resuming normal operations
[Sun Sep 17 11:18:00.664848 2017] [core:notice] [pid 3826] AH00094: Command line: ‘/usr/sbin/apache2’[Sun Sep 17 11:23:26.679253 2017] [mpm_prefork:notice] [pid 3826] AH00169: caught SIGTERM, shutting down
[Sun Sep 17 11:23:32.237928 2017] [ssl:warn] [pid 3937] AH01906: 127.0.1.1:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)[Sun Sep 17 11:23:32.238166 2017] [ssl:warn] [pid 3937] AH01909: 127.0.1.1:443:0 server certificate does NOT include an ID which matches the server name
[Sun Sep 17 11:23:32.727313 2017] [ssl:warn] [pid 3938] AH01906: 127.0.1.1:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)[Sun Sep 17 11:23:32.727609 2017] [ssl:warn] [pid 3938] AH01909: 127.0.1.1:443:0 server certificate does NOT include an ID which matches the server name
[Sun Sep 17 11:23:32.746220 2017] [mpm_prefork:notice] [pid 3938] AH00163: Apache/2.4.25 (Raspbian) OpenSSL/1.0.2l configured – resuming normal operations[Sun Sep 17 11:23:32.746464 2017] [core:notice] [pid 3938] AH00094: Command line: ‘/usr/sbin/apache2’
~Sun Sep 17 11:18:00.646039 2017] [ssl:warn] [pid 3826] AH01909: 127.0.1.1:443:0~server certificate does NOT include an ID which matches the server name
~Sun Sep 17 11:18:00.664599 2017] [mpm_prefork:notice] [pid 3826] AH00163: Apach~/2.4.25 (Raspbian) OpenSSL/1.0.2l configured – resuming normal operations
~Sun Sep 17 11:18:00.664848 2017] [core:notice] [pid 3826] AH00094: Command line~ ‘/usr/sbin/apache2’
~Sun Sep 17 11:23:26.679253 2017] [mpm_prefork:notice] [pid 3826] AH00169: caugh

Also, here is php -m output

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/20151012/apc.so’ - /usr/lib/php/20151012/apc.so: undefined symbol: zif_apcu_store in Unknown on line 0
[PHP Modules]
calendar
Core
ctype
date
exif
fileinfo
filter
ftp
gettext
hash
iconv
igbinary
json
libxml
msgpack
openssl
pcntl
pcre
PDO
Phar
posix
readline
redis
Reflection
session
shmop
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
Zend OPcache
zlib

[Zend Modules]
Zend OPcache

Here is what is in /etc/php/7.0/mods-available/apcu.ini
extension=apcu.so
apc.enabled=1
apc.enable_cli=1

Also:

If I go to https://myexample.com Apache2 Default Page says “it works!”

but if I go to

https://myexample.com/nextcloud is where I get the page isn’t working message.

Looks like that’s your problem. I did a Google and it came back with:

Thanks for that link, I tried the fix provided in the link above by adding this to php.ini with no luck:

extension=apcu.so
extension=apc.so
apc.enabled=1
apc.shm_size=256M
apc.ttl=7200
apc.enable_cli=1
apc.gc_ttl=3600
apc.entries_hint=4096
apc.slam_defense=1
apc.serializer=php

I also tried putting this in apcu.ini as well, and that did not work After adding those files I did a sudo service apache2 restart as well as a reboot of the Raspberry pi.

I’m going to try and keep working on the PHP warning error, and see what I can find. If anyone has further suggestions, thank you in advance.

Update: It looks like APCu is not compatible with php 7.0. I thought I was running php 5.x but I wasn’t. NextCloud tells me I’m using Php 5.6.22. This is confusing me! Will I have luck with memcached or redis? Can I use Zend Opcache for data caching?

I created a thread with a similar question, but didn’t want to intrude as mine was slightly different. I have a similar issue on cPanel/WHM, except I am running php 7.2, I assume the same issue is present. I would also like to know if Opcache can be used for data caching. If not, I can use multiphp to run 5.x in addition to 7.x, if you have WHM/cPanel you can check that out too @MrpTech

The APCu module is definitely not loaded in your case since it does not appear with php -m. Please check if the apcu.ini appears in /etc/php/7.0/apache2/conf.d/, should be symlinked here as 20-apcu.ini.

Otherwise the module was not enabled successfully. If phpenmod apcu does not work to solve it, do the symlink by yourself of apcu.ini to 20-apcu.ini into the mentioned folder.

On the other hand Nextcloud tells you that php5 is used? Did you verify this by creating and checking phpinfo.php? In that case there would be something messed up with your PHP installation and I would completely remove and reinstall it fresh.

Ah and remove the apc.so line in php.ini. It should be just apcu.so (but settings stay apc.enabled etc.). Otherwise you should get some error about missing file ;).

1 Like

Michalng, A quick question before I do the steps in your last message. Will uninstalling PHP and reinstalling have any effect on my current NextCloud install? I will try all of the above steps when I get home from work later today. Thank you.

No Nextcloud + data + it’s configuration works independent from PHP. If you anyway worry about something of nextcloud could break, just put it into occ maintenance:mode --on to prevent any manipulation in between.

EDIT
AHHH!! Sorry you told in OT that you use PHP5. Sorry I mixed it up with the other topic. So Nextcloud should not show you something different of course.
In this case some folders and commands change slightly.

  1. the relates APCu package might be apt install php5-apcu or php5-apc.
  2. The php config folder is /etc/php5/apache2 respectively mods-available.
  3. The command to enable the module (create the symlink) is php5enmod.

So the 5 appears everywhere :smile:.

1 Like

Okay, so I seem to have a php (with php7.) directory and php 5.0 directory…

When I run sudo php5enmod apcu this is what I get:

sudo php5enmod apcu
WARNING: Module apcu ini file doesn’t exist under /etc/php5/mods-available
WARNING: Module apcu ini file doesn’t exist under /etc/php5/mods-available

I’m using Raspbian on the pi (16.04)
I did sudo apt-get purge php.*
then
sudo apt-get install php-apcu (php5-apcu and php5-apc did not work) I got this message however:

WARNING: Not enabling the apcu module for PHP 7.0 cli SAPI since the module
WARNING: was disabled by local administrator.
php_invoke apcu: no action - module was disabled by maintainer for PHP 7.0 cli sapi

After reinstall of php I can not do php5enmod or php7enmod

I did try phpenmod apcu and it worked now I still can’t access owncloud…I’m going to try the phpinfo.php

when opening a browser after creating phpinfo.php and pasting the <?php phpinfo(); ?> and saving did not work.

This site can’t be reached

localhost refused to connect.
Search Google for localhost phpinfo
ERR_CONNECTION_REFUSED

/etc/php/7.0/apache2/conf.d $ ls
10-opcache.ini 20-exif.ini 20-phar.ini 20-sysvsem.ini
10-pdo.ini 20-fileinfo.ini 20-posix.ini 20-sysvshm.ini
20-apcu_bc.ini 20-ftp.ini 20-readline.ini 20-tokenizer.ini
20-apcu.ini 20-gettext.ini 20-shmop.ini
20-calendar.ini 20-iconv.ini 20-sockets.ini
20-ctype.ini 20-json.ini 20-sysvmsg.ini

/etc/php5/mods-available $ ls -al
total 8
drwxr-xr-x 2 root root 4096 Sep 18 19:18 .
drwxr-xr-x 3 root root 4096 Sep 18 19:18 …

I did a new php -m and apcu is now listed

php -m
[PHP Modules]
apc
apcu
calendar
Core
ctype
date
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
openssl
pcntl
pcre
PDO
Phar
posix
readline
Reflection
session
shmop
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
Zend OPcache
zlib

[Zend Modules]
Zend OPcache

I also went to php.ini and renabled opcache.enable=1

[opcache]
; Determines if Zend OPCache is enabled
opcache.enable=1

; Determines if Zend OPCache is enabled for the CLI version of PHP
opcache.enable_cli=1

; The OPcache shared memory storage size.
opcache.memory_consumption=128

; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=8

; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 1000000 are allowed.
opcache.max_accelerated_files=10000

; The maximum percentage of “wasted” memory until a restart is scheduled.
;opcache.max_wasted_percentage=5

; When this directive is enabled, the OPcache appends the current working
; directory to the script key, thus eliminating possible collisions between
; files with the same name (basename). Disabling the directive improves
; performance, but may break existing applications.
;opcache.use_cwd=1

; When disabled, you must reset the OPcache manually or restart the
; webserver for changes to the filesystem to take effect.
;opcache.validate_timestamps=1

; How often (in seconds) to check file timestamps for changes to the shared
; memory storage allocation. (“1” means validate once per second, but only
; once per request. “0” means always validate)
opcache.revalidate_freq=1

; Enables or disables file search in include_path optimization
;opcache.revalidate_path=0

; If disabled, all PHPDoc comments are dropped from the code to reduce the
; size of the optimized code.
opcache.save_comments=1

I ran sudo less /var/log/apache2/error.log
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php5/2013122
6/apcu.so’ - /usr/lib/php5/20131226/apcu.so: cannot open shared object file: No
such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php5/2013122
6/apc.so’ - /usr/lib/php5/20131226/apc.so: cannot open shared object file: No su
ch file or directory in Unknown on line 0

I did some more digging and I do not have a ‘/usr/lib/php5/2013122
6/apcu.so’ directory with apcu.so…but…

I do have this directory…/usr/lib/php/20151012/apcu.so

what do I do now?

So after about a week of trying to configure this, one workaround for this problem is to nuke and pave and install NextCloudPi. If anyone else is having this issue on the Raspberry Pi, the NextCloudPi image has APCu configured by default when installed. I just learned about the officially supported project, and had I started with this, it would have been much easier! Thanks for all the help to everyone who posted here!

Sorry for missing reply, did not get some notification about this.

There seemed to be not clear which php version you are using. The commanda and config files you used point towards php7, but the error shows that it want’s to run the apcu library for php5 which is missing.
In such cases carefully check for every installed php package and purge all of them and then install the new ones again, all with php7.0-name. Since Raspbian was released with Stretch, there is php7.0 available, but if the apt sources were not yet changed, there would be just the php5 packages available.

I guess especially the php common package is important: php5-common or php7.0-common. Just one should be installed.

But yeah, using NextcloudPi is of course a good solution if a new image is an option.

Thank’s

apt install php-apcu

config.php:
‘memcache.local’ => ‘\OC\Memcache\APCu’,

Thats how it works :slight_smile:

1 Like

Sorry to necro, but I think there isn’t a straight answer to the OP…reinstalling isn’t always an option.

If you are using php7+ and php-fpm (on a raspberry pi stretch), the fpm service needs to be manually restarted after adding apcu. ie sudo systemctl restart php7.0-fpm.service…simply restarting the apache server does not do this automatically for you (same for making changes to fpm/php.ini). This may be worth mentioning in the documentation relating to the errors that tend to come up on a new NC install:

  1. “your php opcache settings are not right” and 2) “no memcaching set up”.

Hopefully this helps someone googling for a similar problem.

1 Like

The hint for restarting fpm helped me, thanks!

This worked perfectly for me. PHP 8.1