Ubuntu Default PHP Version - A few questions

SYSTEM INFORMATION
OS type and version Ubuntu Linux 22.04.3
Virtualmin version 7.9.0

Background

  • I am new to the linux universe. :smile:
  • When I installed Ubuntu it came with PHP 8.1 ( I think) pre-installed and this is called the default PHP version.
  • You can install different PHP versions by adding an additional repository
  • I know you can change the default PHP version, maye with the command update-alternatives (or similar command)

So I have few questions

  • Why do you have to install an additional repository to add in new PHP versions? should they not just be in the main repository?
  • What happens if you uninstall the Ubuntu default PHP version?

thanks

Why would you ever want to do that?
I guess it might never get updated with the latest/current/best PHP for that OS (or maybe it would just be updated/re-installed)

because they are out of date for your current OS

Why would you ever want to do that?

Things get uninstalled by accident. Just curious for disaster recovery point of view.

because they are out of date for your current OS

When you add the ondrej repo you can add 7.4 and old version of PHP or you can add php 8.3 which did not come with my Ubuntu and is newer that 8.3.

There must be another reason. :smile:

Accident! do you let that happen?

ondrej repo is something you choose to add - maybe, but you make that choice.
I still cannot see any reason to install a out-of-date version of PHP.
Especially major versions < 8 (current) or even future versions (that could have potential problems with the OS)

If you are doing this just to support bad/out-of-date web apps there needs to be a conversation with the support team for that web application. Just because it can be done by using the ondrej repo and Virtualmin doesn’t mean it should be done.
I think you will find that many of the major commercial VPS providers (I know Ionos does) charge their clients extra for maintaining/supporting out-of-date PHP versions.

Accident! do you let that happen?

pop quiz: If I give you a load of Ubuntu OS Version numbers, can you tell me of the top of your head what their system default PHP version is? I can’t :smile:

I still cannot see any reason to install a out-of-date version of PHP.

I can, there are many, but my question is not about running a web server which I can do, but more why do i need a separate repo for the additional PHP versions?

No and I can’t remember how to program in Cobol or Algol either but once I used to be able to do that. Ancient history needs to be confined to the past. that is especially true of PHP versions < 7. One day it may well apply to Ubuntu. But for now Ubuntu 20 and 22 are all that matter (other OS types accordingly)

the separate repro - as I said above why should the current OS support anything else?

Ubuntu, in this case, will only support 1 version of PHP per distro release to ensure that everything works as expected within that release. Using a different version of PHP than the one Ubuntu (in this case) could cause system instability problems or instability with other installed software (E.G apache/nginx) The ondrej repo allows you to install other versions of PHP if you prepared to take the risk of an unstable system, which in a production environment is not what you want, but from a PHP developers point of view it allows the developer to edit their code to suit the up and coming version of PHP and to also check backwards compatibility with older versions of PHP.
So recap in a production environment use the maintainers (Ubuntu etc) version if your a php developer install & activate the version you wish to code to.
Downside is the ondrej/remi repros are available to all so you can install whichever at your own peril.

2 Likes

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