"occ setupchecks" fails with "opcache_get_status() returns false"

Nextcloud version :
Operating system and version: Debian GNU/Linux 12 (bookworm) ; Version: 12.4
nginx version : 1.22.1
PHP version 8.2.15

The issue you are facing:

I ran occ setupchecks and encountered this error:

PHP opcache: The PHP OPcache module is not properly configured. OPcache is not working as it should, opcache_get_status() returns false, please check configuration.
The maximum number of OPcache keys is nearly exceeded. To assure that all scripts can be kept in the cache, it is recommended to apply "opcache.max_accelerated_files" to your PHP configuration with a value higher than "10000".
The OPcache buffer is nearly full. To assure that all scripts can be hold in cache, it is recommended to apply "opcache.memory_consumption" to your PHP configuration with a value higher than "128".
The OPcache interned strings buffer is nearly full. To assure that repeating strings can be effectively cached, it is recommended to apply "opcache.interned_strings_buffer" to your PHP configuration with a value higher than "16"..

Steps to fix it:
You must make these changes to /etc/php/<php_ver>/cli/php.ini


The solution is to document this requirement in:

Yess! That one is new since 28 :+1:

That defaults to 1, so there is no need to explicitly set it → here you find the defaults ←

This one is important to improve cron jobs!

Since the occ command runs the cli sapi, it can not say much about the right php configuration for your server.
All the other important settings about your opcache must be set in /etc/php/<php_ver>/fpm/php.ini as well, since that sapi is the one your nginx speaks with :wink:

It is already documented:

here: → ini-values ←

here: → enable-php-opcache ←

and here: → memory-caching ←

Do you think the manual should be improved on this point?

Much and good luck,

In my testing, I had to enable both entries in the php.ini file under the cli directory.

I had read about OpCache being enabled by default and I tried not setting opcache.enable=1 in the cli/php.ini file, but it did not work.

Perhaps that default is only for fpm. I can confirm opcache.enable did not need to be enabled to be on by default. The PHP default values page does not specify which php.ini file is being referenced, but they don’t work identically. Perhaps there is an error there also with PHP.

I scoured those documentation pages for any reference to settings for opcache.enable or opcache.enable_cli. There was only one place that “opcache.enable” exists and that only refers to the other two pages.

I did make the same changes in both php.ini files as directed, except for opcache.enable_cli, which had no reference in the fpm version.

So, to answer your question, the manual needs to explain to add both those parameters to the cli/php.ini file to enable OpCache. It could also mention to test this setting with occ setupchecks.

The fact that his impacts the cron jobs makes this more important to get right!

Note that the Administration, Overview does not tag this problem.

Thank you for your prompt attention.

1 Like

I know this ticket is a few months old, but I stumbled accross the same problem and figured that enabling opcache.enable_cli in /etc/php/8.1/cli/php.ini, does not yield correct results.
If you think about it, there is a reason why there are two different config files, one for apache2 and one for the cli.
So in order to check whether your Apache2 will do things correctly for your Nextcloud installation, you would first have to put opcache.enable_cli = 1 into /etc/php/8.1/apache2/php.ini. and then you would have to run setupchecks like this:

sudo -u www-data php -c /etc/php/8.1/apache2/php.ini /usr/share/nextcloud/occ setupcheck

… I guess.