Nextcloud 18: Zend OPcache can't be temporary enabled

Hello:

My stack is:
Nextcloud: 18.0.11
PHP-FPM: Version 7.4.13
Apache: 2.4.25
Debian 9 Stretch

The warning in Nextcloud log is:

Zend OPcache can’t be temporary enabled (it may be only disabled till the end of request) at Unknown#0

However the PHP OPCache is enabled in this web via php.ini.

I have found this warning reported in the forum but I have not found any solution about it

What happens?
There must are some additional configuration in Nextcloud config.php to recognize PHP opcache?

nextcloud.log:

{“reqId”:“s6RawtsxhpC9xkIQTmSY”,“level”:3,“time”:“2020-12-14T09:27:55+00:00”,“remoteAddr”:“www.xxx.yyy.zzz”,“user”:“#”,“app”:“PHP”,“method”:“GET”,“url”:“/ocs/v2.php/core/navigation/apps?absolute=true&format=json”,“message”:“Zend OPcache can’t be temporary enabled (it may be only disabled till the end of request) at Unknown#0”,“userAgent”:“Mozilla/5.0 (Windows) mirall/3.0.2stable-Win64 (build 20200924) (Nextcloud)”,“version”:“18.0.11.2”}
{“reqId”:“bXUVdZgFydFRssS646Ix”,“level”:3,“time”:“2020-12-14T09:27:55+00:00”,“remoteAddr”:“www.xxx.yyy.zzz”,“user”:“#”,“app”:“PHP”,“method”:“PROPFIND”,“url”:“/remote.php/dav/files/*****/”,“message”:“Zend OPcache can’t be temporary enabled (it may be only disabled till the end of request) at Unknown#0”,“userAgent”:“Mozilla/5.0 (Windows) mirall/3.0.2stable-Win64 (build 20200924) (Nextcloud)”,“version”:“18.0.11.2”}

config.php:

$CONFIG = array (

  'instanceid' => '*****',
  'passwordsalt' => '******',
  'secret' => '******',
  'trusted_domains' =>
  array (
    0 => '****.com',
  ),
  'datadirectory' => '/*****.com',
  'memcache.local' => '\\OC\\Memcache\\Memcached',
  'memcache.distributed' => '\\OC\\Memcache\\Memcached',
  'dbtype' => 'mysql',
  'version' => '18.0.11.2',
  'overwrite.cli.url' => 'https://****.com',
  'dbname' => '*****',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '*********',
  'dbpassword' => '******',
  'integrity.check.disabled' => true,
  'installed' => true,
  'filelocking.enabled' => 'true',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'maintenance' => false,
  'loglevel' => 2,
  'mysql.utf8mb4' => true,
  'updater.release.channel' => 'stable',
  'trashbin_retention_obligation' => 'auto,365',
  'app_install_overwrite' =>
  array (
    0 => 'ransomware_protection',
    1 => 'files_texteditor',
  ),
);

php.ini:>

opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1
opcache.error_log=/var/log/php-opcache.log

memory_limit = 512M
upload_max_filesize = 1000M
max_execution_time= 3600
post_max_size = 8M
always_populate_raw_post_data=-1

session.save_handler = redis
session.save_path = "/var/run/redis/redis.sock?persistent=1&weight=1&database=0

phpinfo():

Zend opcache

Opcode Caching Up and Running
Optimization Enabled
SHM Cache Enabled
File Cache Disabled
Startup OK
Shared memory model mmap
Cache hits 35524
Cache misses 946
Used memory 22291640
Free memory 111926088
Wasted memory 0
Interned Strings Used memory 2929352
Interned Strings Free memory 3361656
Cached scripts 946
Cached keys 1785
Max keys 16229
OOM restarts 0
Hash keys restarts 0
Manual restarts 0

Directive Local Value Master Value
opcache.blacklist_filename no value no value
opcache.consistency_checks 0 0
opcache.dups_fix Off Off
opcache.enable On On
opcache.enable_cli On On
opcache.enable_file_override Off Off
opcache.error_log /var/log/php-opcache.log /var/log/php-opcache.log
opcache.file_cache no value no value
opcache.file_cache_consistency_checks On On
opcache.file_cache_only Off Off
opcache.file_update_protection 2 2
opcache.force_restart_timeout 180 180
opcache.huge_code_pages Off Off
opcache.interned_strings_buffer 8 8
opcache.lockfile_path /tmp /tmp
opcache.log_verbosity_level 1 1
opcache.max_accelerated_files 10000 10000
opcache.max_file_size 0 0
opcache.max_wasted_percentage 5 5
opcache.memory_consumption 128 128
opcache.opt_debug_level 0 0
opcache.optimization_level 0x7FFEBFFF 0x7FFEBFFF
opcache.preferred_memory_model no value no value
opcache.preload no value no value
opcache.preload_user no value no value
opcache.protect_memory Off Off
opcache.restrict_api no value no value
opcache.revalidate_freq 1 1
opcache.revalidate_path Off Off
opcache.save_comments On On
opcache.use_cwd On On
opcache.validate_permission Off Off
opcache.validate_root Off Off
opcache.validate_timestamps On On`

1 Like

You use different webserver and you need distributed caches? In this case, you probably want to add some memcache servers: Memory caching — Nextcloud latest Administration Manual latest documentation

Thank you for your suggestion.
I have set

‘memcache.distributed’ => ‘\OC\Memcache\Redis’,

and also i have tried to deleted

‘memcache.distributed’

and leave only

‘memcache.local’ => ‘\OC\Memcache\Memcached’,

but the error message remain the same

Zend OPcache can’t be temporary enabled (it may be only disabled till the end of request) at Unknown#0

1 Like

Just for curiosity. Have you fixed?

Yes, is solved. The solution is here:

https://ma.ttias.be/php-warning-zend-opcache-cant-temporary-enabled/

The problem is when default php.ini contained this value:

opcache.enable = 1

and in the PHP-FPM pool configuration tried to enable opcache again

Since i had a hard time finding a solution for this problem on a Debian 11 root server with PHP running as FPM, i’m adding it here:

When adding the opcache configuration to “/etc/php/8.1/fpm/pool.d/my_virtual_host.conf” i got the annoying message about opcache not properly configured. Both opcachge-gui and phpinfo() showed the opposite. I finally got rid of the message when i moved all opcache configuration from the fpm-pool file to the global “/etc/php/8.1/fpm/php.ini” configuration. After a restart of the php8.1-fpm service i finally got the green checkmark in the admin section of Nextcloud…

Maybe this helps someone.

2 Likes

@happenpappen Marry me!!! :rofl:

Finally a solution to this annoying problem… Spent weeks looking for this solution… since 2021, when I decided to include optcache on my server, had it on my admin overview…

Cheers to you for taking the time to post that :raised_hands:

I already disabled the PHP-FPM pool configuration and the error still pops up. What more can be done?

What is the echo of

grep -r opcache.enable /etc/php

Normaly

… should not be set at all, since it defaults to 1.

See: PHP: Runtime Configuration - Manual


ernolf