issue when installing php-dev in ubuntu 20.04

@Henning Kockerbeck's explanation is great. Here is the 2-line solution presented at this blog post

Copy-pasting the code to avoid link-rot in the future:

# apt install libssl-dev
The following packages have unmet dependencies:
libssl-dev : Depends: libssl1.1 (= 1.1.1-1ubuntu2.1~18.04.9) but 1.1.1d-1+ubuntu18.04.1+deb.sury.org+2 is to be installed
E: Unable to correct problems, you have held broken packages.

This explains the various versions that are in conflict, due to which you might have to "hold" a package to a particular version which appears to apt as the not-latest version:

# apt-cache policy libssl1.1
libssl1.1:
  Installed: 1.1.1g-1+ubuntu18.04.1+deb.sury.org+1
  Candidate: 1.1.1g-1+ubuntu18.04.1+deb.sury.org+1
  Version table:
 *** 1.1.1g-1+ubuntu18.04.1+deb.sury.org+1 100
        100 /var/lib/dpkg/status
     1.1.1-1ubuntu2.1~18.04.9 500
        500 http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
     1.1.0g-2ubuntu4 500
        500 http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

This installs a specific version. Remember that this is a time-bomb and when you want to upgrade later you have remove this version of the package / unhold it.

# apt install libssl1.1=1.1.1-1ubuntu2.1~18.04.9 

Now the versions are OK and php7.x-dev will install properly

# apt-cache policy libssl1.1
libssl1.1:
  Installed: 1.1.1-1ubuntu2.1~18.04.9
  Candidate: 1.1.1-1ubuntu2.1~18.04.9
  Version table:
 *** 1.1.1-1ubuntu2.1~18.04.9 500
        500 http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
        100 /var/lib/dpkg/status
     1.1.0g-2ubuntu4 500
        500 http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

The minor versions above may vary, but the idea is the same - Sury's packages are causing an issue with system's libssl package. There must be other solutions to keep using Sury's version of libssl, after all he has been maintaining these packages for a decade, which means he must know what he is doing, but I'm not aware of the details of such an alternative approach.


It seems like you have old packages from a PPA installed that throw things into disarray.

You try to install php7.4-dev. That package depends on php7.4-common. For Ubuntu 20.04, php7.4-common actually is 7.4.3-4ubuntu2.4.

But you already have a php7.4-common package installed, namely 7.4.11-6+ubuntu16.04.1+deb.sury.org+1. This seems to be a package for about eight Ubuntu versions ago, but with a slightly newer PHP version (7.4.11 vs. 7.4.3). So apt prefers the supposedly newer package. But 7.4.11-6+ubuntu16.04.1+deb.sury.org+1from the PPA doesn't work with php7.4-dev from Ubuntu 20.04s repositories. So apt is throwing up its proverbial hands up and gives up.

If you don't need it anymore, you should remove the PPA and all packages installed from it. Maybe there are additional PPAs or packages throwing things in disarray, but the above seems to be a problem in any case.