Nextcloud upgrade and PHP memory_limit, apc_enable_cli

Nextcloud upgrade and PHP memory_limit, apc_enable_cli

We tried to upgrade Nextcloud and this time hit:

PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 442368 bytes) in /var/www/nextcloud/3rdparty/composer/autoload_real.php on line 35

error.

So the php.ini and how it should be configured are explained here (https://haydenjames.io/understanding-php-memory_limit/)

What I didn’t understand well was:

So, for example, if two or more scripts are requested simultaneously, each is completely independent of the other. They do not share the memory_limit setting. Remember, PHP is not designed for and does not support multithreading. Thus, if five (5) PHP scripts are simultaneously using 100MB each, that would total 500MB of PHP memory usage, and a PHP memory limit of 128M wouldn’t be hit.

Now thanks to the article we changed the php.ini setting and re-tried upgrading of Nextcloud. (We set it to 2048M in fact.)


apc.enable_cli

However we still were having error:

OCP\HintException: [0]: Memcache \OC\Memcache\APCu not available for local cache

Some discussions in community:

https://github.com/nextcloud/server/issues/27781

https://help.nextcloud.com/t/where-can-i-find-apc-enable-cli/85168/2

And so we follow the instructions here too to

1.Made sure required libraries are installed: sudo apt install php7.4-cli php7.4-common php-apcu

2. Added apc.enable_cli=1 to our php.ini located in: /etc/php/7.4/cli/php.ini

; https://help.nextcloud.com/t/where-can-i-find-apc-enable-cli/85168/4
apc.enable_cli=1

3. Reloaded apache config:

sudo systemctl reload apache2

Now the upgrade command did work:

$ sudo -u www-data php7.4 /var/www/nextcloud/occ upgrade
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Setting log level to debug
Updating database schema
Updated database
Starting code integrity check…
Finished code integrity check
Update successful
Maintenance mode is kept active
Resetting log level

Well so we upgraded Nextcloud to 24.0.5 finally: