I know a lot of topics have the same question but I’ve tried everything and nothing works for me.
So I’m trying to install php 7.4 on my ubuntu stretch. I’ve done the following commands I found on the Internet:
apt install ca-certificates apt-transport-https wget gnupg
wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add -
echo "deb https://packages.sury.org/php/ buster main" | tee /etc/apt/sources.list.d/php.list
apt update
apt install php7.4
And then I get the error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php7.4 : Depends: libapache2-mod-php7.4 but it is not going to be installed or
php7.4-fpm but it is not going to be installed or
php7.4-cgi but it is not going to be installed
Depends: php7.4-common but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I saw that someone followed the error by trying to install the depedencies that were causing the problem. So I then did
apt install php7.4-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php7.4-common : Depends: libc6 (>= 2.27) but 2.24-11+deb9u4 is to be installed
E: Unable to correct problems, you have held broken packages.
I saw somewhere that it could be something in my /etc/apt/sources.list so here it is:
# Generated by distrobuilder
deb http://deb.debian.org/debian stretch main
deb http://security.debian.org/debian-security stretch/updates main
I’m stuck, I don’t see what’s wrong. Could you help? Thanks
2
Answers
If you don’t have a specific dependency for PHP v7.4, you can try installing v7.3 instead and that will work just fine. I ran into the same issue in my Kali Linux but since I just needed PHP and not a specific version, installing 7.3 worked for me.
You can achieve this with
sudo apt-get install php7.3
please try below commands for Ubuntu: