Feature Request: Persistent PHP Configuration Overrides for Nextcloud on NethServer 8

Problem

The Nextcloud administration overview reports:

The PHP OPcache module is not properly configured. The OPcache buffer is nearly full. To assure that all scripts can be held in cache, it is recommended to apply opcache.memory_consumption with a value higher than 128.

In the current NethServer 8 Nextcloud implementation (ghcr.io/nethserver/nextcloud-app:1.7.0), there is no documented or obvious way to persistently override PHP settings such as:

  • opcache.memory_consumption
  • opcache.max_accelerated_files
  • opcache.interned_strings_buffer
  • other PHP-FPM and PHP runtime parameters

The container uses internal configuration files under:

/usr/local/etc/php/conf.d/

but these files are recreated whenever the container is rebuilt or updated.

Current Situation

Administrators can temporarily modify PHP settings inside the running container, for example:

opcache.memory_consumption=512

However, such changes are lost when:

  • the application is updated,
  • the container is recreated,
  • the application is restored from backup,
  • NethServer regenerates the container.

Requested Enhancement

Provide an officially supported mechanism to persist PHP overrides for Nextcloud applications.

Possible implementations:

Option 1: UI Configuration

Add a section in the Nextcloud application settings:

PHP Configuration Overrides

allowing administrators to define custom PHP directives.

Option 2: Persistent Custom INI File

Provide a host-side file such as:

~/.config/state/php-custom.ini

which is automatically mounted into the container and loaded after the default configuration.

Option 3: Advanced Configuration Field

Add support for custom PHP settings in the application configuration JSON.

Benefits

  • Resolves OPcache warnings without modifying containers manually.
  • Survives updates and container recreation.
  • Reduces support requests related to PHP tuning.
  • Allows administrators to optimize larger Nextcloud installations.
  • Aligns with the persistent configuration model already used for Nginx and PHP-FPM settings.

Example Use Cases

opcache.memory_consumption=512
opcache.max_accelerated_files=20000
opcache.interned_strings_buffer=64
memory_limit=2G
upload_max_filesize=10G
post_max_size=10G

These settings are commonly required for medium and large Nextcloud deployments and should be configurable without modifying the container image.

It’s already possible to customize PHP, see for example NS8 NextCloud single file limit - #5 by mrmarkuz

From the Nextcloud Github README:

You can customize FPM configuration by changing the file named zzz_nethserver.conf inside the state directory. Example:

runagent -m nextcloud1 vi zzz_nethserver.conf

Hi Markus,

thanks for the pointer to zzz_nethserver.conf – that works well for PHP-FPM pool settings. However, I need to remove from “Solved / Solution”: For OPcache directives it does not apply, because OPcache is configured via php.ini or environment variables, not via FPM pool configuration.

The actual solution for persistent opcache.memory_consumption on NS8 Nextcloud:

The container reads its environment from /home/nextcloud2/.config/state/config.env (passed as --env-file in the systemd unit). The variable PHP_OPCACHE_MEMORY_CONSUMPTION is defined in the container image with a default of 128, but is not present in config.env.

Adding it there makes the change persistent across updates and container recreations:

echo "PHP_OPCACHE_MEMORY_CONSUMPTION=256" >> /home/nextcloud2/.config/state/config.env

After restarting the module via the NS8 GUI, the warning is gone.

This might be worth adding to the Nextcloud module README as the canonical way to tune OPcache memory.

I propose to return this to a feature request

3 Likes

I have just spent a couple of hour trying to find out how to increase the OPcache. Be useful to see this in the docs.

1 Like