4

I have a fresh install of Ubuntu 24.10 and I have PHP8.3 installed.

> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.10
Release:    24.10
Codename:   oracular
> php -v
PHP 8.3.11 (cli) (built: Sep 30 2024 12:07:44) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.11, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.11, Copyright (c), by Zend Technologies
    with Xdebug v3.2.0, Copyright (c) 2002-2022, by Derick Rethans

Because of work I need to use PHP 8.2, PHP 8.1, PHP 8.0 and PHP 7.4.

When I try to install them through apt-get it cannot find the packages and after adding the Ondrej PPA running apt update I see the error Error: The repository 'https://ppa.launchpadcontent.net/ondrej/php/ubuntu oracular Release' does not have a Release file.

How can I install the older PHP versions on my Ubuntu 24.10 installation?

Maarten
  • 234

2 Answers2

5
sudo add-apt-repository --remove ppa:ondrej/php
sudo add-apt-repository ppa:ondrej/php
sudo sed -i 's/oracular/noble/g' /etc/apt/sources.list.d/ondrej-ubuntu-php-oracular.sources
sudo apt update
sudo apt install php8.2 php8.1 php8.0 php7.4

You can install the Ondrej PPA and overwrite its release suites tag so apt install can get the packages from the 24.04 (Noble) version of Ubuntu.

You can probably skip this step but for good measure, remove the Ondrej PPA if you already have it added and add it back again;

sudo add-apt-repository --remove ppa:ondrej/php
sudo add-apt-repository ppa:ondrej/php

Now open the Ondrej sources file and change the suite from oracular to noble;

sudo sed -i 's/oracular/noble/g' /etc/apt/sources.list.d/ondrej-ubuntu-php-oracular.sources

Run apt update

sudo apt update

When apt update is successful, you can start installing the older PHP packages!

sudo apt install php8.2 php8.1 php8.0 php7.4

The result:

> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.10
Release:    24.10
Codename:   oracular
> php8.2 -v
PHP 8.2.24 (cli) (built: Sep 27 2024 04:05:15) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.24, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.24, Copyright (c), by Zend Technologies
> php8.1 -v
PHP 8.1.30 (cli) (built: Sep 27 2024 04:07:54) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.30, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.30, Copyright (c), by Zend Technologies
> php8.0 -v
PHP 8.0.30 (cli) (built: Sep 27 2024 04:11:42) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.30, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.30, Copyright (c), by Zend Technologies
> php7.4 -v
PHP 7.4.33 (cli) (built: Sep 27 2024 04:14:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies


If you need to execute composer with a specific PHP version you can do the following;

php7.4 /usr/local/bin/composer update

If the composer command is not found and you can execute it with a simple composer, you can find the full path to composer using which composer. Use that path in the above command and you will execute composer with the specified PHP version.


I am using composer and have lots of packages. So I needed the following packages;
sudo apt install php7.4-dom php7.4-dev php7.4-mbstring php7.4-tokenizer php7.4-xml php7.4-xmlwriter php7.4-curl php7.4-gd php7.4-soap -y
sudo apt install php8.0-dom php8.0-dev php8.0-mbstring php8.0-tokenizer php8.0-xml php8.0-xmlwriter php8.0-curl php8.0-gd php8.0-soap -y
sudo apt install php8.1-dom php8.1-dev php8.1-mbstring php8.1-tokenizer php8.1-xml php8.1-xmlwriter php8.1-curl php8.1-gd php8.1-soap -y
sudo apt install php8.2-dom php8.2-dev php8.2-mbstring php8.2-tokenizer php8.2-xml php8.2-xmlwriter php8.2-curl php8.2-gd php8.2-soap -y
Maarten
  • 234
0

bad idea updating dist to beta on working machine, try to use previous ppa dist version of Noble, it should be:

https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble InRelease