The PHP OPcache module is not loaded

Nextcloud version: 21.0.5
Operating system and version: Debian 10 (buster)
Apache or nginx version: 2.4.38
PHP version: 7.3

The issue you are facing:

Nextcloud complains that the OPCache module isn’t loaded

Is this the first time you’ve seen this error?: N

Output of sudo php -m:

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

[Zend Modules]
Zend OPcache

Output of sudo php -i | grep -i opcache:

/etc/php/7.3/cli/conf.d/10-opcache.ini,
    with Zend OPcache v7.3.29-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies
Zend OPcache
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/nextcloud/opcache.log => /var/log/nextcloud/opcache.log
opcache.file_cache => /var/www/nextcloud/data/.opcache => /var/www/nextcloud/data/.opcache
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 => 4 => 4
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.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

Here we can see that PHP reads OPCache as enabled and recognizes the options. For consistency’s sake I added opcache.error_log which also gets populated with logs like:

Sun Oct  3 13:30:01 2021 (5240): Message File cached script loaded into memory '/var/www/nextcloud/apps/activity/lib/BackgroundJob/DigestMail.php'
Sun Oct  3 13:30:01 2021 (5240): Message File cached script loaded into memory '/var/www/nextcloud/apps/activity/lib/DigestSender.php'
Sun Oct  3 13:30:01 2021 (5240): Message File cached script loaded into memory '/var/www/nextcloud/apps/activity/lib/UserSettings.php'
Sun Oct  3 13:30:01 2021 (5240): Message File cached script loaded into memory '/var/www/nextcloud/apps/activity/lib/GroupHelper.php'
Sun Oct  3 13:30:01 2021 (5240): Message File cached script loaded into memory '/var/www/nextcloud/lib/private/Security/Bruteforce/CleanupJob.php'
Sun Oct  3 13:30:01 2021 (5240): Message File cached script loaded into memory '/var/www/nextcloud/apps/user_status/lib/BackgroundJob/ClearOldStatusesBackgroundJob.php'
Sun Oct  3 13:30:01 2021 (5240): Message File cached script loaded into memory '/var/www/nextcloud/apps/user_status/lib/Db/UserStatusMapper.php'
Sun Oct  3 13:30:01 2021 (5240): Message File cached script loaded into memory '/var/www/nextcloud/apps/user_status/lib/Service/StatusService.php'
Sun Oct  3 13:30:01 2021 (5240): Message File cached script loaded into memory '/var/www/nextcloud/lib/public/UserStatus/IUserStatus.php'

This should already indicate that the module is working, but the overview page complains regardless.

The output of your config.php file in /path/to/nextcloud:

<?php
$CONFIG = array (
  'passwordsalt' => 'secret',
  'secret' => 'secret',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'secret',
    2 => 'secret',
    11 => 'secret',
  ),
  'datadirectory' => '/mnt/md0/data',
  'dbtype' => 'mysql',
  'version' => '21.0.5.1',
  'overwrite.cli.url' => 'secret',
  'htaccess.RewriteBase' => '/',
  'dbname' => 'secret',
  'dbhost' => 'secret',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'secret',
  'dbpassword' => 'secret',
  'installed' => true,
  'instanceid' => 'secret',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
    'password' => 'secret',
  ),
  'default_phone_region' => 'secret',
  'tempdirectory' => '/var/www/nextcloud/data/tmp',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'secret',
  'mail_from_address' => 'secret',
  'mail_domain' => 'secret',
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'overwriteprotocol' => 'https',
  'maintenance' => false,
  'loglevel' => 1,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'logdateformat' => 'd-m-Y H:i:s',
  'theme' => '',
  'updater.release.channel' => 'stable',
  'updater.secret' => 'secret',
);

Any help would be greatly appreciated.

I have experienced the same problem when updating to 21.0.5 and now to 22.2.0. I also am getting the following for sodium.

  • This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them.
    sodium

Yet both of these things are loaded and showing up in both phpinfo.php and PHP -m.

Something has changed with these updates as I was never getting these errors before.

[PHP Modules]
apcu
bcmath
brotli
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
imagick
imap
intl
json
libxml
mailparse
mbstring
mcrypt
memcache
memcached
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
pspell
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
ssh2
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
uploadprogress
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

As you can see both opcache and sodium are loaded and included in my php.ini.
Here is my opcache data from php -i | grep -i opcache

/opt/alt/php-fpm80/usr/php/php.d/opcache.ini,
    with Zend OPcache v8.0.11, Copyright (c), by Zend Technologies
Zend OPcache
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 => no value => no value
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.jit => tracing => tracing
opcache.jit_bisect_limit => 0 => 0
opcache.jit_blacklist_root_trace => 16 => 16
opcache.jit_blacklist_side_trace => 8 => 8
opcache.jit_buffer_size => 0 => 0
opcache.jit_debug => 0 => 0
opcache.jit_hot_func => 127 => 127
opcache.jit_hot_loop => 64 => 64
opcache.jit_hot_return => 8 => 8
opcache.jit_hot_side_exit => 8 => 8
opcache.jit_max_exit_counters => 8192 => 8192
opcache.jit_max_loop_unrolls => 8 => 8
opcache.jit_max_polymorphic_calls => 2 => 2
opcache.jit_max_recursive_calls => 2 => 2
opcache.jit_max_recursive_returns => 2 => 2
opcache.jit_max_root_traces => 1024 => 1024
opcache.jit_max_side_traces => 128 => 128
opcache.jit_prof_threshold => 0.005 => 0.005
opcache.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 5000 => 5000
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.record_warnings => Off => Off
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 60 => 60
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

opcache has been moved into opcache.ini You don’t need to set it in php.ini on CentOS 7

I am still experiencing the sodium error, looks like something in Nextcloud.