PHP fails on Ubuntu 20.04

Hi there,

I’m running into an issue with existing (older) trellis projects that still run on Ubuntu 20.04.
Whenever I try to spin up a new VM on an existing project with trellis init and trellis up I’m getting this error:

TASK [php : Install PHP and extensions] ****************************************
failed: [default] (item=php8.2-bcmath) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.2-bcmath", "value": "present"}, "msg": "No package matching 'php8.2-bcmath' is available"}
failed: [default] (item=php8.2-cli) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.2-cli", "value": "present"}, "msg": "No package matching 'php8.2-cli' is available"}
failed: [default] (item=php8.2-curl) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.2-curl", "value": "present"}, "msg": "No package matching 'php8.2-curl' is available"}
failed: [default] (item=php8.2-dev) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.2-dev", "value": "present"}, "msg": "No package matching 'php8.2-dev' is available"}
failed: [default] (item=php8.2-fpm) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.2-fpm", "value": "present"}, "msg": "No package matching 'php8.2-fpm' is available"}
failed: [default] (item=php8.2-imagick) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.2-imagick", "value": "present"}, "msg": "No package matching 'php8.2-imagick' is available"}
failed: [default] (item=php8.2-intl) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.2-intl", "value": "present"}, "msg": "No package matching 'php8.2-intl' is available"}
failed: [default] (item=php8.2-mbstring) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.2-mbstring", "value": "present"}, "msg": "No package matching 'php8.2-mbstring' is available"}
failed: [default] (item=php8.2-mysql) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.2-mysql", "value": "present"}, "msg": "No package matching 'php8.2-mysql' is available"}
failed: [default] (item=php8.2-xml) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.2-xml", "value": "present"}, "msg": "No package matching 'php8.2-xml' is available"}
failed: [default] (item=php8.2-xmlrpc) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.2-xmlrpc", "value": "present"}, "msg": "No package matching 'php8.2-xmlrpc' is available"}
failed: [default] (item=php8.2-zip) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.2-zip", "value": "present"}, "msg": "No package matching 'php8.2-zip' is available"}

I’m pretty sure it has to do with the fact that Ubuntu 20.04 has reached end-of-life support
for it’s LTS standard security maintenance in May 2025:

Because of that, the ppa:ondrej/php package is unable to install PHP or any extensions on Focal Fossa:

https://stackoverflow.com/questions/79709025/faild-to-install-php-8-3-on-ubuntu-20-04

Also re-provisioning any remote server running on Ubuntu Focal Fossa results in this error:

TASK [common : Update apt packages] ********************************************
fatal: [167.172.45.117]: FAILED! => {"changed": false, "msg": "Failed to update apt cache: W:This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details., E:Repository 'http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease' changed its 'Label' value from '***** The main PPA for supported PHP versions with many PECL extensions *****' to 'PPA for PHP'"}

But I can fix that by running sudo apt update and accepting the changes in the http://ppa.launchpad.net/ondrej/php/ubuntu repository.

Locally it’s easy for me to update to Ubuntu 24.04 LTS, that fixes the [php : Install PHP and extensions] task, however I have at least 20+ live droplets running on Ubuntu 20.04 still.

It’s a LOT of work to create new droplets for each one of them and sync all content especially since we don’t control the DNS records for a lot of our clients.

So my question basically is;
Is there a workaround to keep running existing Ubuntu 20.04 projects with a different PHP package? Or is there a smarter way to upgrade existing droplets to Ubuntu 22.04 or 24.04?

I’m aware you can do it with sudo do-release-upgrade following this guide:

https://www.digitalocean.com/community/tutorials/how-to-upgrade-to-ubuntu-22-04-jammy-jellyfish

But I’m a bit hesitant to do this on live droplets.
Any insights are appreciated.

Thanks!

This is one of the downsides of managing servers yourself :sweat_smile:

When I ran into this, I provisioned new servers and then swapped the DNS. Trying to manually upgrade a production server’s Ubuntu version seems sketchy to me, and kind of defeats the purpose of using Trellis.

If you happen to be using DigitalOcean, they have floating/reserved IPs that could help you avoid multiple DNS changes in the future.

True, but sometimes quicker then having to wait for some IT guy at your client’s office to update the DNS records :grin:

I actually just tried the sudo do-release-upgrade method on a DO staging droplet, first from:
20.04 LTS (Focal Fossa)22.04 LTS (Jammy Jellyfish)
22.04 LTS (Jammy Jellyfish)24.04 LTS (Noble Numbat)

And it went pretty smooth to be honest, only downtime of around ~5-6 mins!

I am, but either way you have to edit the DNS records, either by updating to the new droplet IP or by updating to the new reserved IP.

I just noticed that Digital Ocean now also has Reserved IPv6 Addresses! That was one of the reasons I didn’t use it that much yet.

1 Like

I wonder what would happen if you try to re-provision the server after you’ve manually upgraded :eyes:

That’s the first thing I tried :slight_smile:
And I had no errors whatsoever, I was suprised too!

1 Like

:partying_face:

Good to know, thank you the post and the updates! Should be helpful for others with old servers

1 Like