I have two Raspberry Pi's:

  • a Raspberry Pi 2 with Raspbian GNU/Linux 8 (jessie)
  • a Raspberry Pi 4 with Raspbian GNU/Linux 10 (buster).

I was able to get multiple versions of PHP running on the Raspberry Pi 4 by adding deb http://ppa.launchpad.net/ondrej/php/ubuntu bionic main to /etc/apt/sources.list.d/ondrej-ubuntu-php.list and then by doing apt-get update.

Trying the same thing on the Raspberry Pi 2 is proving fruitless. So first, I'm not doing bionic - I'm doing trusty, per the table at https://askubuntu.com/a/445496/180177. eg. I did deb http://ppa.launchpad.net/ondrej/php/ubuntu trusty main to /etc/apt/sources.list.d/ondrej-ubuntu-php.list and then by doing apt-get update. I also had to do https://superuser.com/a/1674197/172193 to get apt-get update to work. But then, when I do sudo apt-get install php5.6 -y I get this error:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php5.6
E: Couldn't find any package by regex 'php5.6'

Now, one might wonder

  • Why don't I update the OS?
  • Why am I not trying to install a newer version of PHP?

That'd be because I'm trying to scope out a bug that I'm only able to reproduce on the Raspberry Pi 2. Right now the Raspberry Pi 2 has PHP 7.2.0, which was released on 30 Nov 2017, which reproduces the issue. However, on the Raspberry Pi 4, not even PHP 5.6.40, released on 10 Jan 2019, reproduces the issue.

If I could get PHP 5.6.40 running on the Raspberry Pi 2 I could see if the issue is still present. If it is that would suggest that the issue is with the Raspberry Pi 2, itself. Or maybe with one of the dependencies that PHP uses. But it wouldn't necessarily be an issue with PHP itself. Alternatively, if it isn't an issue, then that would suggest that the issue was fixed for all PHP versions between Nov 2017 and Jan 2019. I'm not seeing anything about such a change in the changelogs but that assumes that all changes are in the changelogs.

I suppose I could compile a new version of PHP on the Raspberry Pi 2 but I'm a little worried that if I do that I might overwrite my PHP 7.2.0 install (the only install I've been able to reproduce this issue on).

  • 2
    Jessie is obsolete. Installing code from other OS is a recipe for disaster.
    – Milliways
    Jul 19, 2022 at 11:02
  • @Milliways - I am aware. However, that Jessie install is also the only way I'm able to reproduce an esoteric bug in a software package of mine. If I update the OS then I'm afraid I might all together lose my ability to reproduce the issue. I suppose I could tell my client to go f*ck themselves but I'd rather not, if at all possible. I addressed this in the last four paragraphs of my question
    – neubert
    Jul 19, 2022 at 11:06
  • As for installing code from other OSs being a disaster... I'm doing that on the Raspberry Pi 4 without issue. The apt repo I added is for Ubuntu - not for Raspbian. Maybe using an Ubuntu apt repo on Jessie won't work as well as it does on Buster but I figure the damage will be confined to new apps I might install and that damage I might be able to deal with better on my own than I am this issue. I don't pretend to understand apt internals, hence my question
    – neubert
    Jul 19, 2022 at 11:12
  • Another idea for this might be to use another microSD card to do testing on. That way you can preserve the broken example install pristine. Jul 28, 2022 at 15:35

2 Answers 2


http://ppa.launchpad.net/ondrej/php/ubuntu/dists/trusty/main/binary-armhf/ contains no packages, that's why apt can't find them. You should be able to get PHP 5.6 from http://legacy.raspbian.org/raspbian/dists/jessie/main/binary-armhf/, that will probably be easier than installing Ubuntu packages on Raspbian.

PHP 7.2 seems to be available in buster, did you try to install it on Pi 4 to see if the issue is still there?

  • 1
    I ultimately was able to get this working (I suppose I can answer it as time permits) but the issue is present on all versions of PHP 7.0, PHP 7.1.0 through 7.1.23 and PHP 7.2.0 through 7.2.11. The issue is not mentioned in the PHP changelogs but I found the commit that introduced the error and the one that fixed it. I'm able to reproduce it on a Pi 4 with the latest EOL version of PHP 7.0, using the ondrej repo
    – neubert
    Jul 21, 2022 at 16:05

I wound up just downloading and compiling PHP on my own and then changing the name of the binary to have the version number appended to it. eg.

wget https://museum.php.net/php7/php-7.2.11.tar.gz
tar xvzf php-7.2.11.tar.gz
cd php-7.2.11
./configure --disable-fileinfo
make install-cli
mv /usr/local/bin/php /usr/local/bin/php7.2.11
sudo update-alternatives --install /usr/local/bin/php php /usr/local/bin/php7.2.11 11

idk how this would work with extensions but, for my purposes, extensions were not something I needed to worry about.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.