Error Opcache is not properly configured

Nextcloud version (eg, 20.0.5): 28.0.5
Operating system and version (eg, Ubuntu 20.04): Debian 12
Apache or nginx version (eg, Apache 2.4.25): 2.4.59
PHP version (eg, 7.4): 8.2.18
MariaDB : 11.2.3
The issue you are facing:
while checking the opcache, I noticed errors when running the command “sudo -u www-data php /var/www/nextcloud/occ setupchecks -vv”

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. sudo -u www-data php /var/www/nextcloud/occ setupchecks -vv
  2. and the error is displayed in red

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "",
        "overwrite.cli.url": "https:\/\/",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "default_phone_region": "FR",
        "htaccess.RewriteBase": "\/",
        "trashbin_retention_obligation": "auto, 30",
        "filelocking.enabled": "true",
        "knowledgebaseenabled": false,
        "activity_expire_days": 7,
        "skeletondirectory": "\/var\/www\/extra_nextcloud\/skeleton\/",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": "0",
            "timeout": "0.0"
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "mail_smtpmode": "smtp",
        "mail_smtpsecure": "ssl",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "default_language": "fr",
        "default_locale": "fr_FR",
        "": "stable",
        "maintenance_window_start": 1,
        "maintenance": false,
        "enable_previews": true,
        "enabledPreviewProviders": {
            "1": "OC\\Preview\\BMP",
            "2": "OC\\Preview\\GIF",
            "3": "OC\\Preview\\JPEG",
            "4": "OC\\Preview\\Krita",
            "5": "OC\\Preview\\MarkDown",
            "6": "OC\\Preview\\MP3",
            "7": "OC\\Preview\\OpenDocument",
            "8": "OC\\Preview\\PNG",
            "9": "OC\\Preview\\TXT",
            "10": "OC\\Preview\\XBitmap",
            "11": "OC\\Preview\\Image",
            "12": "OC\\Preview\\HEIC",
            "13": "OC\\Preview\\TIFF",
            "14": "OC\\Preview\\Movie",
            "15": "OC\\Preview\\MP4",
            "16": "OC\\Preview\\PDF"
        "preview_max_x": 1024,
        "preview_max_y": 1024,
        "preview_concurrency_all": 32,
        "preview_concurrency_new": 16,
        "preview_max_filesize_image": 200,
        "preview_max_memory": 1024,
        "preview_ffmpeg_path": "\/usr\/bin\/ffmpeg",
        "theme": "",
        "loglevel": 2,
        "defaultapp": ""

The output of your Apache/nginx/system log in /var/log/____:

No error in apache2

Error Opcache

opcache PHP: The PHP OPcache module is not correctly configured. OPcache does not work as expected, opcache_get_status() returns false, please check the configuration.
The maximum number of OPcache keys is almost exceeded. To ensure that all scripts can be cached, it is recommended to set the "opcache.max_accelerated_files" variable in your PHP configuration file to a value greater than "10000".
The OPcache memory buffer is almost full. To ensure that all scripts can be cached, it is recommended to set the "opcache.memory_consumption" variable in your PHP configuration file to a value greater than "128".
The OPcache internal strings memory buffer is almost full. To ensure that repetitive strings can be cached, it is recommended to set the "opcache.interned_strings_buffer" variable in your PHP configuration file to a value greater than "8".

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

no error

opcache section of php.ini

; Determines if Zend OPCache is enabled

; Determines if Zend OPCache is enabled for the CLI version of PHP

; The OPcache shared memory storage size.

; The amount of memory for interned strings in Mbytes.

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

; The maximum percentage of "wasted" memory until a restart is scheduled.

; 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.

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

; 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)

; Enables or disables file search in include_path optimization

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

; If enabled, compilation warnings (including notices and deprecations) will
; be recorded and replayed each time a file is included. Otherwise, compilation
; warnings will only be emitted when the file is first cached.

; Allow file existence override (file_exists, etc.) performance feature.

; A bitmask, where each bit enables or disables the appropriate OPcache
; passes


; The location of the OPcache blacklist file (wildcards allowed).
; Each OPcache blacklist file is a text file that holds the names of files
; that should not be accelerated. The file format is to add each filename
; to a new line. The filename may be a full path or just a file prefix
; (i.e., /var/www/x  blacklists all the files and directories in /var/www
; that start with 'x'). Line starting with a ; are ignored (comments).

; Allows exclusion of large files from being cached. By default all files
; are cached.

; Check the cache checksum each N requests.
; The default value of "0" means that the checks are disabled.

; How long to wait (in seconds) for a scheduled restart to begin if the cache
; is not being accessed.

; OPcache error_log file name. Empty string assumes "stderr".

; All OPcache errors go to the Web server log.
; By default, only fatal errors (level 0) or errors (level 1) are logged.
; You can also enable warnings (level 2), info messages (level 3) or
; debug messages (level 4).

; Preferred Shared Memory back-end. Leave empty and let the system decide.

; Protect the shared memory from unexpected writing during script execution.
; Useful for internal debugging only.

; Allows calling OPcache API functions only from PHP scripts which path is
; started from specified string. The default "" means no restriction

; Mapping base of shared memory segments (for Windows only). All the PHP
; processes have to map shared memory into the same address space. This
; directive allows to manually fix the "Unable to reattach to base address"
; errors.

; Facilitates multiple OPcache instances per user (for Windows only). All PHP
; processes with the same cache ID and user share an OPcache instance.

; Enables and sets the second level cache directory.
; It should improve performance when SHM memory is full, at server restart or
; SHM reset. The default "" disables file based caching.

; Enables or disables opcode caching in shared memory.

; Enables or disables checksum validation when script loaded from file cache.

; Implies opcache.file_cache_only=1 for a certain process that failed to
; reattach to the shared memory (for Windows only). Explicitly enabled file
; cache is required.

; Enables or disables copying of PHP code (text segment) into HUGE PAGES.
; Under certain circumstances (if only a single global PHP process is
; started from which all others fork), this can increase performance
; by a tiny amount because TLB misses are reduced.  On the other hand, this
; delays PHP startup, increases memory usage and degrades performance
; under memory pressure - use with care.
; Requires appropriate OS configuration.

; Validate cached file permissions.

; Prevent name collisions in chroot'ed environment.

; If specified, it produces opcode dumps for debugging different stages of
; optimizations.

; Specifies a PHP script that is going to be compiled and executed at server
; start-up.

; Preloading code as root is not allowed for security reasons. This directive
; facilitates to let the preloading to be run as another user.

; Prevents caching files that are less than this number of seconds old. It
; protects from caching of incompletely updated files. In case all file updates
; on your site are atomic, you may increase performance by setting it to "0".

; Absolute path used to store shared lockfiles (for *nix only).

command used to configure opcache

sed -i -e "s/^;* *opcache\.enable *= *.*$/opcache.enable=1/g" /etc/php/8.2/apache2/php.ini
sed -i -e "s/^;* *opcache\.memory_consumption *= *.*$/opcache.memory_consumption=512/g" /etc/php/8.2/apache2/php.ini
sed -i -e "s/^;* *opcache\.interned_strings_buffer *= *.*$/opcache.interned_strings_buffer=128/g" /etc/php/8.2/apache2/php.ini 	 
sed -i -e "s/^;* *opcache\.max_accelerated_files *= *.*$/opcache.max_accelerated_files=100000/g" /etc/php/8.2/apache2/php.ini 	 
sed -i -e "s/^;* *opcache\.revalidate_freq *= *.*$/opcache.revalidate_freq=60/g" /etc/php/8.2/apache2/php.ini
sed -i -e "s/^;* *opcache\.save_comments *= *.*$/opcache.save_comments=1/g" /etc/php/8.2/apache2/php.ini

I have the impression that the parameters are not taken applied by Nextcloud because I control the opcache parameters by executing:

cat /etc/php/8.2/apache2/php.ini | \
	egrep "^;* *opcache\.enable *=|^;* *opcache\.interned_strings_buffer *=\
	|^;* *opcache\.max_accelerated_files *=|^;* *opcache\.memory_consumption *=\
	|^;* *opcache\.save_comments *=|^;* *opcache\.revalidate_freq *=\
	|^;* *opcache\.interned_strings_buffer*="

I have the following result:


the parameter “opcache.memory_consumption ,opcache.revalidate_freq” is missing.

I have no errors in the nextcloud interface , but only when I run “sudo -u www-data php /var/www/nextcloud/occ setupchecks -vv”

Do you think my configuration has errors?
Thanks for your help

I also get this error when I run “sudo -u www-data php /var/www/nextcloud/occ setupchecks -vv”.
I haven’t figured out how to solve this in Docker yet.

Are there more, that the apache2 folders in the folder?
In that case you will find more than one php.ini.

thank you for the answer, yes I thought about it and modifying the Opcache settings in all the php.ini files, but it does not work (I restart Apache and php each time I try). I modified the php.ini of apache2, cli and fpm. but nothing works

The problem appears only if you run the occ command. The occ command makes use of the php-cli SAPI.

You must add this setting to the


opcache.enable_cli = 1

to activate the opcache for the CLI SAPI (Command Line Interface Server API)

Much and good luck,

1 Like

The apache2-SAPI and the fpm-SAPI are mutualy exclusive.
You should consider to remove (purge) the not used SAPI, to reduce noise on your server.

You can run the php-updater script to exactly see, which SAPI your server is using to communicate with PHP.

The shipped help explains in detail the difference between the various SAPIs.

Much and good luck,

1 Like

thank you for your help, I used your script, but I did not complete the installation, because I was asked to install several packages, and I am afraid of breaking my system, here is an image of the packages offered.

Using your instructions, I no longer have opcache errors
thanks a lot for your help

1 Like

Don’t worry, those packages can’t break your system or make it unusable. However, an incorrectly set PHP could definitively.
But I like your caution. If only everyone were so careful, it would definitely be very quiet here :wink:
If you have a young system (e.g. debian bookworm) and everything is running well, then you don’t have to do anything.
Especially since there are cases where both libapache2-mod-php and php-fpm are needed. For example, if you have both the Apache2 and the Nginx web server running…

Much and good luck,

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.