Does Ubuntu update the system PHP version

OS type and version Ubuntu Linux 22.04.3
Webmin version 2.105
Usermin version 2.005
Virtualmin version 7.9.0
Theme version 21.09.5
Package updates 1 package update is available


When I setup Ubunutu I am sure the system PHP version was 8.1 and I have not changed the system default however I have installed other PHP version from Ondrej PPA repo.

If I check on the Ubuntu packages website it implies that the system default should be php 8.1

The question

During normal operation of an Ubuntu server will the OS upgrade PHP from 8.1 → 8.3?

Or has something else happened?


If this does happen and PHP 8.3 already exists because I have installed it via the Ondrej PPA repo, do the updates overwrite this additional version?

What happens to the old system PHP version?


Nope as mentioned elsewhere 1 version per distro version release (e.g 20.04 etc) so when you upgrade to 24.04 I would guess php 8.3 will be the default version. With virtualmin it is good practice to install a new distro version on a new instance rather than upgrading an existing instance to avoid software issues, which in turn means php wont be already installed

thanks jimr1, that what I thought would happen.

But it appears that when i install a newer version of php from the ondrej repository, the system default is automatically upgraded to this version (if newer: i.e. 8.1 → 8.3).

If you install an older version, the same does not apply.

on I have the following version of PHP installed: 7.4.33, 8.1.27, 8.2.14 : the default is 8.2.14
on I have the following version of PHP installed: 7.1.33, 7.4.33, 8.0.30, 8.1.27, 8.2.15, 8.3.2 : the default is 8.3.2

I have not run the command update-alternatives


If you have the ondrej repository enabled, then all php package updates (most of them) will come from the ondrej repo because it has priority.

that’s the cli version of php and not the version used by apache virtual hosts, for example change the php version for a domain, log to ssh as that user (or webmin terminal) and do php -v again you may get a different result

i used the command php -v

root@example:~# php -v

PHP (cli) (built: Jan 20 2024 14:16:40) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.2, Copyright (c) Zend Technologies
    with Zend OPcache, Copyright (c), by Zend Technologies

Just in-case, I am on about the Ubuntu system default PHP version. I ran the command as root in webmin.

If I log in as a user via SSH I will get that users PHP version as assigned in the virtual server. The version the Apache hosts use is specified and these are operating as normal. My client accounts have not change what PHP version they.

The default cli PHP version should not of changed either but this is the only one I can access to use the default PHP

The symlinks for the default version must be updated when a newer version is detected. I installed php7.1 and this did not change the system default PHP. Unfortunately I have already installed 8.3 on my test server and I dont want to mess with my love server at the minute to double check installing a later version of PHP changes the system default.

Well I mentioned that to the dev’s ages ago, as it is not an error condition to have apache/nginx to have php 7.4 running & a program exec to another php version which is different. It gets worse as they way this has been implemented means all sub servers have the same cli version of PHP. The fix is to delete the symlink /home/<user>/etc/php.ini then you get the default version back

If you install a newer version of PHP on Ubuntu, then it will become the default version for the command line.

Looks like it might be a thing.


php8.3-cli installs the PHP CLI, and symlinks /usr/bin/php to /usr/bin/php8.3.

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.