Score:7

How to install php7.4, 5.6 ubuntu 21.10

de flag

How to install the old version of PHP. It does not work at the moment repository

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

Then:

The repository 'http://ppa.launchpad.net/ondrej/php/ubuntu impish Release' does not have a Release file.
in flag
Could you elaborate on “it does not work”? Does this mean Apache is not rendering the PHP? Or does this mean you cannot install 7.4 specifically? Do you see any error messages?
in flag
i've tried the answer from [Tadeáš Fryčák](https://askubuntu.com/a/1369856/1494720) and it works for me.
Score:5
ug flag

I've had similar problem and I solved it by:

sudo nano /etc/apt/sources.list.d/ondrej-ubuntu-php-impish.list

then replacing impish (Ubuntu 21.10) with focal (Ubuntu 20.04) on the first line in the file to this:

deb http://ppa.launchpad.net/ondrej/php/ubuntu/ focal main

and then

sudo apt install php5.6
calin24 avatar
cn flag
This is not a good solution. If you have php 8 and want to install another version ex: 7.4 it will conflict some libraries... I hope ondrej will add the repo for ubuntu 21.10
Foreen avatar
ug flag
I agree, but as a temporary fix, it's better than nothing.
Score:5
cn flag

Rather than edit or change the above answers I wanted to mention that the PPA supports 21.10 now.

sudo add-apt-repository ppa:ondrej/php

You can install multiple version of PHP with this PPA. But by default 8 is in the repos, but if you need older versions this PPA will solve that problem.

It should be noted that this PPA outlines a few things noted below. CAVEATS:

  1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
  2. If you are using apache2, you are advised to add ppa:ondrej/apache2
  3. If you are using nginx, you are advised to add ppa:ondrej/nginx-mainline    or ppa:ondrej/nginx

Just to be extra helpful here, if you need to change the default PHP version use this command.

sudo update-alternatives --config php
de flag
Worked like a charm, thanks! No longer a need for the work around in the original answer tagged as correct.
Score:2
zw flag

Currently the mentioned PPA does not provide packages for Ubuntu 21.10. You have to disable it by

sudo add-apt-repository -r -y ppa:ondrej/php

and then use PHP 8.0 from official repositories.

To get your simple PHP page rendered by Apache use commands below:

sudo apt-get install libapache2-mod-php
sudo service apache2 restart

cat << EOF | sudo tee /var/www/html/phpinfo.php
<?php
phpinfo();
?>
EOF

and then navigate your web-browser to http://localhost/phpinfo.php .

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.