Using the ubuntu php ppa and metapackages

What is the safest way to install newer versions of php on a Ubuntu vmin server using the sury PPA?

Is it recommended that I remove all (or some) of any php metapackages before I add the sury ppa? Doing that isn’t mentioned on this page:

Nor is doing so mentioned here:

However, I know I have had php break in the past due to performing upgrades after adding he sury ppa when php gets a point update. Sometimes not all of the php modules get updated at the same time as the main php packages and this causes breakages. I think this could be avoided if no php metapackages are installed before adding the ppa and doing updates.

Part of the problem might be because I didn’t run a vmin config check after php got upgraded?

This is further complicated as I don’t think I was able to remove all of the php metapackages I had installed last time I tried to do this. There was at least one php metapackage I could not remove and that was before adding the PPA.

How do other Ubuntu vmin server admins approach using the sury PPA for newer php versions? Its a bit risky using this PPA I’d say but there is big demand from my users for the latest version of php and we can’t upgrade to the latest Ubuntu yet. We’ve only just installed 22.04.

On a related note, and I realise his is not the fault of the vmin devs, I find it really annoying how every point release of php has a separate set of config files. Whose idea was that?

@danboid,

If you are installing an LTS to gain the benefits of what LTS stands for, you should typically be using the distro version of PHP as any other version “may” introduce issues that cause your system to be less stable.

That being said, you are welcome to install other versions of PHP along side the one installed by your distro or depending on your distro version, perhaps an upgrade to the latest LTS is in fact a better option (assuming you just want a newer version of PHP).

Follow the instructions at the following URL to install multiple versions of PHP:

The documentation was created for those interested in having multiple versions of PHP, however keep in mind my earlier point about the potential side effects. Generally speaking, going outside the lines of what the distro supports is *** at your own risk ***

I can say however with confidence, that the PHP versions made available by “deb.sury.org” (the one you referenced “PPA”) are pretty safe given the following statement from the developer:

Cheers!

We are using security software not supported under 24.04 so we’re stuck on 22.04 for a while yet.

I’m pretty sure both pages I linked to should be advising against the use of metapackages for php as the php metapackage wiil always auto download the latest point release if you have the PPA enabled.

I suppose I was hoping for a known working command to remove all of the php metapackages but I don’t think there is one.

@danboid,

Well, if you’re using the PPA’s version of PHP, typically the PPA is not the same version installed with the distro… Then I’m not sure what issues the meta packages would create.

Perhaps you can explain further, as I’m sure if there was a case for this, it’d be posted on “deb.sury.org”…

Assuming the issue is new however, perhaps you could report it to the repo developers like “deb.sury.org” as assuming it’s relevant and important, they’d surely make the adjustment to their docs or whatever is required to address.

As for the docs on Virtualmin, they’re pretty much just basing their information on the ones provided upstream by the repo developers along with some user friendly context.

*** while I do stand to my original comment about recommending usage of distro version of PHP and/or other packages for “most” users, I personally do make use of the “deb.sury.org” on select machines and have never run into any issues, installing, and using as-is ***

BTW, you can at your discretion disable “certain” versions of PHP tracked and updated by “deb.sury.org” via the repo file typically found within:

/etc/apt/sources.list.d/

There is also, as I recall a CLI way of doing the above step as well. Just can’t think of the syntax ATM.

I think I’m in luck actually

I ran this script

apt-cache show $(dpkg-query -Wf '${Package}\n') | 
  awk '$1 == "Package:" { pkg = $2 }; 
       $1 == "Section:" && $2 ~ /metapackage/ { print pkg }'

and I don’t seem to have any php metapackages installed. Yay!

I would recommend Ubuntu and Debian users run this before adding the sury repo and avoid installing any php metapackages.

That page assumes you’re starting with a Virtualmin installation that doesn’t have any extra PHP packages beyond the ones provided by the OS vendor that were installed by the Virtualmin installer.

If you’ve followed other docs on the web for installing PHP, it’s very likely you installed mod_php, which you should never do. So, if you’ve installed mod_php you should uninstall it. If you just install php or php83-php, that will install mod_php (well, you can make it not do so by providing the dependency some other way, but you don’t need that metapackage, so don’t install it). If that’s the metapackage you’re talking about, you shouldn’t have installed it, and you should uninstall it.

I am only aware of problems if you have mod_php installed, which will break other execution modes every time it updates. So, don’t do that.

You should be specific about what package and what error. But, if it was a metapackage that depended on mod_php (which is in the libapache-mod-php package) then you obviously should have never installed it, and you should do whatever you need to do to uninstall it, because it will continue to break your system forever.

There is no scenario where you should have mod_php installed.