Php-updater - a script to upgrade php in a safe way

@ernolf

Thank you so much for your efforts! :pray:
It worked.

@bb77
I’m using Debian 11.11

Ah ok, looks like ansifilter is only available in the current stable release (Debian 12), testing (upcoming Debian 13) and unstable (sid): ansifilter - Debian Package Tracker

Hi,

i downloaded your script, but i“m not able to install it.

when i try to run it, i get following error:

Screenshot 2025-10-24 093155

i“m on HandssonIT VM

Hi @alex156,

You must install the jq package:

sudo apt-get install jq

If that doesnt solve it, run

sudo apt-get install --reinstall jq

h.t.h.


ernolf

installing jq worked for me. php is now updated. thank you!

I had to get the script from here: https://global-social.net/raw/scripts/php-updater

I had an issue running this script on Hannsson IT VM. I previously used this script a year or so ago to get me to PHP 8.3 without issue.

Had a snaphot, ran the script twice, got the same results. Upon successful completion of script and PHP 8.4 being active, I was unable to exit Maintenance Mode via OCC, and was getting Internal Server Errors. I kept getting this error:

An unhandled exception has been thrown:
OCP\HintException: [0]: Memcache OC\Memcache\Redis not available for local cache (Is the matching PHP module installed and enabled?)

So I re-ran the script to compare 8.3 > 8.4 components, and this was the output:

## actual PHP related packages installed and managed by dpkg
X   Package                Version                                       Status

* php8.3-bcmath          8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: bcmath
* php8.3-bz2             8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: bz2
  SAPI php8.3-cli             8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\php binary /usr/bin/php8.3 <<INACTIVE not linked
* php8.3-common          8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included modules: calendar ctype exif ffi fileinfo ftp gettext iconv pdo
  phar posix shmop sockets sysvmsg sysvsem sysvshm tokenizer
* php8.3-curl            8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: curl
* php8.3-dev             8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  SAPI php8.3-fpm             8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\listening on unix socket /run/php/php8.3-fpm.nextcloud.sock <<NOT CONNECTED
* php8.3-gd              8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: gd
* php8.3-gmp             8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: gmp
* php8.3-igbinary        3.2.16-3+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: igbinary
* php8.3-imap            8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: imap
* php8.3-intl            8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: intl
* php8.3-ldap            8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: ldap
* php8.3-mbstring        8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: mbstring
* php8.3-opcache         8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: opcache
* php8.3-pgsql           8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included modules: pdo_pgsql pgsql
* php8.3-readline        8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: readline
* php8.3-redis           6.1.0-2+ubuntu20.04.1+deb.sury.org+1            hm
  \\included module: redis
* php8.3-smbclient       1.1.1-1+ubuntu20.04.1+deb.sury.org+2            hm
  \\included module: smbclient
* php8.3-soap            8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: soap
* php8.3-sqlite3         8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included modules: pdo_sqlite sqlite3
* php8.3-xml             8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included modules: dom simplexml xml xmlreader xmlwriter xsl
* php8.3-zip             8.3.20-1+ubuntu20.04.1+deb.sury.org+1           hm
  \\included module: zip
  SAPI php8.4-cli             8.4.15-1+ubuntu22.04.1+deb.sury.org+1           im
  \\php binary /usr/bin/php8.4  linked to generic /usr/bin/php
* php8.4-common          8.4.15-1+ubuntu22.04.1+deb.sury.org+1           im
  \\included modules: calendar ctype exif ffi fileinfo ftp gettext iconv pdo
  phar posix shmop sockets sysvmsg sysvsem sysvshm tokenizer
  SAPI php8.4-fpm             8.4.15-1+ubuntu22.04.1+deb.sury.org+1           im
  \\listening on unix socket /run/php/php8.4-fpm.nextcloud.sock  apache2
* php8.4-opcache         8.4.15-1+ubuntu22.04.1+deb.sury.org+1           im
  \\included module: opcache
* php8.4-readline        8.4.15-1+ubuntu22.04.1+deb.sury.org+1           im
  \\included module: readline
* php-common             2:96+ubuntu20.04.1+deb.sury.org+1               hm
* php-pear               1:1.10.16+submodules+notgz-2+ubuntu20.04.1+deb.sury.org+1hm
* pkg-php-tools          1.42build1                                      im

Not only was Redis missing from PHP 8.4, but so were a bunch of other modules. I manually installed them from CLI and then was able to end Maintenance Mode, and quick testing of all my apps via web interface and mobile, it appears to be functional. System tab also shows PHP 8.4 as installed now.

I’m not sure why this occurred, but again both attempts did not install all the same PHP8.4 modules that 8.3 had. During the script, it certainly prompted me to copy modified values from 8.3 to applicable 8.4 configs, and Redis was in fact one of those prompts. So I’m confused why it simply did not install all the corresponding modules.

Just posting in case others have this same issue.

Hi @R0gue_One,

Thank you so much for this valuable feedback. I’m already looking into the cause.

I would be even more grateful if you would be willing to open an issue on GitHub with all the relevant information about the VM you’re using. I assume it wasn’t the VM you updated to 8.3 a year ago, or at least you were running scripts from the VM again. In the VM, the modules igbinary, redis, and smbclient aren’t delivered as packages, but for reasons completely incomprehensible to me, they come with poorly constructed, i.e., incorrectly linked, PECL versions.

I hope you haven’t rebooted yet, because important log files that can help me determine the cause are located in
/tmp/ebtb/log/*
It would be great if you could send them to me via PM.

I’d be happy to elaborate on this further on GitHub.


ernolf

The VM is indeed the same VM from a year or so ago. I’ve maintained it by upgrading Ubuntu, PHP, Postgres, etc but it’s still at its core the original machine.

The first time the issue occurred, I did reboot, and got the same command. I then restored my snapshot, enabled Maintenance mode, and ran through it again which failed, which is when I then tried installing components manually.

It’s not been rebooted since then, so I’ll check and see if there is any data in the mentioned logfile.

I may have manually installed smbclient before to deliver a fix for an issue, I don’t recall.

I’ll be happy to open a GitHub issue shortly.

Thank you, Thank you, Thank you
you saved me a holiday in a clinicum :zany_face:
That script ist just great, it found a few small glitches in my config and removed the smbclientstuff, which i did not need at all, saved all my tuningstuff and … well :folded_hands:

Hi,
I run this script when upgrading tot php 8.2 and wanted to run it again. But this time i got this error saying i am missing a binary:

.. loading modules - integrity
First run of php-updater, checking integrity:

ERROR: ā€˜jq’ binary not found.

Any idea how to fix this?

sudo apt-get install jq

h.t.h.

Hello !

I’m currently trying to upgrade PHP on a NC server running on Debian 11.11

I’m trying to use the PHP updater script mentioned in this thread, but it seems that the website is currently unreachable.

I cannot access or download the script from:

https://global-social.net/raw/scripts/php-updater

and the main website https://global-social.net also appears to be down.

Could someone please confirm if the script has been moved to another location, or provide an alternative download source?

Thank you !

Hi @lema,

It should work now. Try again please.

No, there is no other download option. And even if there were, it wouldn’t help you, because the script can only function as long as my server is accessible. So, strictly speaking, it’s not just a simple script, but a remote maintenance system where my server provides the necessary modules, depending on what needs to be done or changed on your server, to ensure everything runs securely and optimally.


ernolf

With the recent changes to the php repos with Ondřej Surý’s PPA packaging for Ubuntu/Debian moving to packages.sury.org/php/, it appears that this script is not working anymore and fails with this error: - Failed to load required module ā€˜php/sury’

Are there any plans to update it?

Read: Ubuntu: apt error "Repository ... ondrej/php ... changed its 'Label' value" - the PPA is moving to packages.sury.org

It works perfectly. Without specific details about your system, I can’t tell you why it isn’t working for you.

ernolf

I was trying to run it on a system and was getting errors finding the php repo over the course of a couple of days. Let me do some digging again to see if it was an issue with dns resolutions at the time. I did experience some quirks with some other attempted updates on other systems at the office around the same time. perhaps my ISP was having some issues.

confirmed that i was having dns issues.

hi, i wanted to update my ubuntu version, but i can“t couse there are some php packages (from php-updater) wich cant be upgraded.

The following packages have been kept back:
php8.1-bcmath php8.1-bz2 php8.1-cli php8.1-common php8.1-curl php8.1-dev php8.1-fpm php8.1-gd php8.1-gmp php8.1-imap php8.1-intl php8.1-ldap php8.1-mbstring php8.1-opcache php8.1-pgsql php8.1-readline
php8.1-soap php8.1-xml php8.1-zip php8.3-apcu php8.3-bcmath php8.3-bz2 php8.3-cli php8.3-common php8.3-curl php8.3-dev php8.3-fpm php8.3-gd php8.3-gmp php8.3-igbinary php8.3-imap php8.3-intl php8.3-ldap
php8.3-mbstring php8.3-opcache php8.3-pgsql php8.3-readline php8.3-redis php8.3-smbclient php8.3-soap php8.3-xml php8.3-zip php8.4-bcmath php8.4-bz2 php8.4-cli php8.4-common php8.4-curl php8.4-dev php8.4-fpm
php8.4-gd php8.4-gmp php8.4-igbinary php8.4-imap php8.4-intl php8.4-ldap php8.4-mbstring php8.4-opcache php8.4-pgsql php8.4-readline php8.4-redis php8.4-smbclient php8.4-soap php8.4-xml php8.4-zip
0 upgraded, 0 newly installed, 0 to remove and 64 not upgraded.


how can i ether update these packages or remove them. i currently use php 8.4 so i somehow have to update it via ubuntu apt comand but i get an error trying this, couse it tells me that the package is broken.

so i wanted to delete all php versions from php-updater and reinstall after ubuntu update, but i dont know how.

E: Unable to correct problems, you have held broken packages.

This is not a php-updater issue. It is what happens to packages from any repository the distribution does not know about, whether that is Sury, a PPA, or the Docker repo.

Sury builds its php packages with version numbers above Ubuntu’s own, and against the libraries of the release you had at the time. When you move to a new release, apt finds packages that are already newer than anything the new release offers, so it keeps them, and then it cannot satisfy their dependencies because those were built for the old libraries. That is both the ā€œkept backā€ and the ā€œheld broken packagesā€.

The rule is the same for every foreign source: disable it before the release upgrade, and put the packages it installed back to the distribution’s own versions. do-release-upgrade disables third party sources for you, but it does not undo the packages that came from them. That part is on you, and it has to happen first.

With three php versions installed at once, the shortest way out is the one you already suggested yourself: purge php completely, upgrade Ubuntu, then run php-updater again on the new release. Save /etc/php first, your FPM pool and your php.ini changes live there and a purge takes them with it.

Right now there is not enough on the table to say anything more specific. Could you post the output of these:

lsb_release -ds
tail -n +1 /etc/apt/sources.list /etc/apt/sources.list.d/* /etc/apt/preferences.d/* 2>/dev/null
apt-cache policy php8.4-fpm
apt-mark showhold
sudo apt-get full-upgrade -s 2>&1 | tail -40

The last one is the important one. The summary line only says that something is wrong; the simulation names the package and the dependency that actually blocks it.