Score:0

How to install PHP 8.1.13 on Ubuntu 22.04 LTS?

am flag

If one installs PHP on Ubuntu 22.04 LTS, by default PHP version 8.1.2 is installed:

$ sudo apt install php
$ php -v
PHP 8.1.2-1ubuntu2.9 (cli) (built: Oct 19 2022 14:58:09) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.9, Copyright (c), by Zend Technologies

If I list what packages are available, I am told that version 8.1.13 is available as php8.1:

$ dpkg -l | grep php
…
ii  php8.1 8.1.13-1+ubuntu22.04.1+deb.sury.org+1 all server-side, HTML-embedded scripting language (metapackage)
…

However, if I try to install it, I am told that it is already installed:

 $ sudo apt install php8.1
 Reading package lists... Done
 Building dependency tree... Done
 Reading state information... Done
 php8.1 is already the newest version (8.1.13-1+ubuntu22.04.1+deb.sury.org+1).
 0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.

However, php8.1 -v (and the php -v – it is symlinked) reports "PHP 8.1.2-1ubuntu2.9".

I also checked the binary, and it is definitively version 8.1.2.

For the record: This has nothing to do with the 7 packages reported as being kept back.

 $ sudo apt upgrade
 …
 The following packages have been kept back:
  grub-common grub-pc grub-pc-bin grub2-common libsasl2-2 libsasl2-modules libsasl2-modules-db
  0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.

I also tried to add the well-known ppa:ondrej/php. It let me install PHP version 8.2.0, but not PHP 8.1.13 (or any other version 8.1.x).

I admit I don't understand what goes on here. Why does apt install tell me "php8.1 is already the newest version (8.1.13-1+ubuntu22.04.1+deb.sury.org+1)" when the -voption tells me otherwise?

Is there a way to install PHP version 8.1.13 on Ubuntu 22.04 LTS?

in flag
Generally, the most effective way to install a very specific version of any software is to use a Docker container. Everything else is transient or unreliable.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.