"The following packages have unmet dependencies" when installing php8.0

14.8k Views Asked by At

I am trying to install php8.0 on my ubuntu VM, but I'm failing horribly. I have been following countless tutorials, such as this one, but I get stopped here when trying to run the sudo apt install php8.0-fpm (I have to use nginx).

What I get, is the following 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:
 php8.0-common : Depends: libffi6 (>= 3.0.10~rc8) but it is not installable
E: Unable to correct problems, you have held broken packages.

I have tried multiple solutions, like the ones shown here, but nothing seems to be fixing the problem (or to be modifying anything actually).

Here are my php version and ubuntu versions:

php -v
PHP 7.4.21 (cli) (built: Jul  1 2021 16:09:59) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.10
Release:        20.10
Codename:       groovy

In case you need to also see my /etc/apt/sources.list file, leave a comment and I will add it.

Do you have any ideas that might work for me? I am not exactly the best Linux user, so in case you have an idea, can you also attach the commands that you want me to try? It would save me a lot of time and research.

Thank you!

2

There are 2 best solutions below

2
On

I managed to finally solve it. I had to manually install the "libffi" library and some other missing ones with:

wget http://mirrors.kernel.org/ubuntu/pool/main/libf/libffi/libffi6_3.2.1-8_amd64.deb

After downloading it, I ran:

dpkg -i libffi6_3.2.1-8_amd64.deb

Hope this helps somebody.

0
On

I got the same issue I used Linux Mint 20 XFCE and then what I did was

I finally succeeded with :

sudo apt remove php

but got

The following packages have unmet dependencies:
libapache2-mod-php8.1 : Depends: php8.1-cli but it is not going to be installed
Depends: libpcre2-8-0 (>= 10.38) but 10.34-7 is to be installed
E: Unable to correct problems, you have held broken packages.

So I installed the dependancy with sudo apt install libpcre2-8-0 And finally

sudo apt install php8.1

and the result is:

$php -v

PHP 8.1.7 (cli) (built: Jun 10 2022 12:22:48) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.7, Copyright (c) Zend Technologies
with Zend OPcache v8.1.7, Copyright (c), by Zend Technologies