Need helping updating PHP beyond 7.4 so I can upgrade NC25

I seem to end up in a deadlock here. I tried a few times updating PHP but this completely breaks NC 25. So each time I rolled back my Snapshot to be able to get NC up and running again. At the same time - if I understand the latest announcement of NC27 correctly - I will never receive an update to NC26 or NC27 because of the PHP version.

So what would be the suggested way to solve this? Update PHP first and simply overwrite my NC25 directory with the NC27 files instead of using the updater?

Distro I am working on:
Ubuntu 20.04.6 LTS (GNU/Linux 5.4.0-153-generic x86_64)
NC installed: 25.0.13
PHP installed: 7.4.33

When trying to update php via apt-get it updates to 8.2 which seems to be incompatible with NC 25

Could you tell use a little more about your setup? Linux distro for starters.

Sorry. This was a comment before moving so it lacks a few details. Will add those (update: added)

most current try:

  1. install php 8.1
apt-get install php8.1
  1. disabling 7.4 support and enabling 8.1 support in apache:
sudo a2dismod php7.4
sudo a2enmod php8.1
systemctl restart apache2

which resulted in a server error when trying to reaccess NC25. Switching the mods back makes it run again but still on 7.4 obviously

That kind of “updating” php is asking for trouble!

php8.1 is only a meta-package and does not install any of the needed pecl packages.

If your nextcloud is runing fine on php7.4, you can update to a new php version using the php-updater script.

First of all, to run the script, you should first uninstall ALL not php7.4 packages on your box.

This is how to list all the installed php packages:

dpkg -l|awk '/^ii.*php/ {print $2}'

you should see some php-packages without a version and some php7.4-packages.
If you see some php8.0 or php8.1 or php7.3, in other words, some php$version packeges where version != 7.4, then you should purge them first from your system:

sudo apt-get purge *php$version*

Now you can install and run the php-updater script:

sudo wget -O /usr/local/bin/php-updater
sudo chmod +x /usr/local/bin/php-updater

If you removed all other php-versions prior to runing this, the script will offer you, to install a new php version (after an integrity check), choose version 8.0 and answer all questions with the given answer.

After the script is ready, you can proceed with the steps you tried before:

I hope this helps you!
Much luck,

1 Like


I would go with php 8.2 then running the updater.phar from the command line.

If Ubuntu allows php 8.2 without upgrading the distro, this should work fine:

sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/updater/updater.phar

Here is a post on a Debian 11 to 12 upgrade, that is kinda related:

1 Like

I ended up removing 7.4 completely, updating to 8.2 and installing NC26 manually (NC27 did not work directly because of a too big version jump). Then had to fix some stuff in the (for all those who might end up here through google; you have to do changes like “apc.enable_cli=1” in BOTH php.inis (cli and apache)

Have a few small issues like a failed integrity check for mimetypes.js. But that is not the scope of this and I assume I can fix that when time comes as all seems to be working more or less as it should

thanks everyone for your help

The requirement to include the above switch in all Nextcloud PHP commands like occ is a right faff :wink: I’ve just written a bash script to include all the preamble needed.

Do you mean, you include apc.enable_cli=1 with a wrapper script?

apc.enable_cli → is only needed if you use APCu as memcache ←

When you want to enable it on cli, you should simply add

apc.enable_cli = 1

to the php.ini of your php-cli, that is all:

php -i | grep "apc.enable_cli"
apc.enable_cli => On => On

If you are using redis as memcache, this is not needed at all.


Yes, I know I can edit the central php.ini file but I often read that you shouldn’t update php.ini unless you really have to. Does it get overwritten with updates? Other php apps also running on the same server. Assume with docker, less of an issue.

So I use a variable called $nextcloudcmd (or script) which contains sudo -i nginx php --define apc.enable_clu=1 /data/nextcloud. I can then run occ with $nextcloudcmd occ etc.

There is a small bug in updater.phar in that it doesn’t pass through any php options but then again, there is a good chance it doesn’t know or is able to access php options like this at runtime.

If a new php.ini file comes, you get asked if you want to overwrite it, as with all config files under /etc/*

This is how it is normaly done:
Edit or create if not yet exists your ~/.bash_aliases and add this:

HT_USER=<your webserver_user e.g. www-data or nginx>
occ() { sudo -u $HT_USER -E php -f "$NC_DIR/occ" "$@"; }
alias nextcloud-update='sudo -u $HT_USER php -d memory_limit=512M -d apc.enable_cli=1 -f $NC_DIR/updater/updater.phar'
# etc.

The reason why I put occ in a function and not in an alias, is because this way the shell completion script works, with occ as an alias it doesn’t.

If you do not add apc.enable_cli=1 to your php.ini is absolutely ok, it is not needed to run occ scripts with apc.enable_cli anyway. Only for some cron jobs. So you only need it in your crontab. But if you want to add it to all your php calls, then this would be the place to do that.

What do you mean? When there is a bug, you should file a bugreport.

Or do you mean, that you can not pass options to updater.phar like --help or --no-interaction

nextcloud-update --help
Usage: php [options] [-f] <file> [--] [args...]

That’s because, if you call updater.phar with php, all further arguments passed will be interpreted as arguments of php.

The trick is to pass a double hyphen “--” before you pass arguments for the updater.phar:

~# nextcloud-update -- --help
  Updates the code of an Nextcloud instance

  update [options]

      --no-backup       Skip backup of current Nextcloud version
      --no-upgrade      Don't automatically run occ upgrade
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

  This command fetches the latest code that is announced via the updater server and safely replaces the existing code with the new one.

Much luck,

I would say it’s debatable whether it’s a bug or a limitation - certainly an issue. I assume that updater.phar is running occ upgrade and this fails without the APC switch.

How would updater.phar know to include the switch when spawning occ?

updater.phar offers to run occ upgrade. I’ve never seen that fail.

apc is not necessary for occ, not even for updater.phar.
But if you absolutely want to have apc activated in all cli scripts, then you have no choice but to enter it in the php.ini for your php-cli as the values for memory consumption, opcache, redis etc. that are also entered there. After all, that’s what the file is there for.

Much luck,

Fails every time for us.