Php-xml depends: php7 4 xml but it is not going to be installed

I have php7.0 installed on Ubuntu 16.04 and I'm trying to install a forum software in apache2, but I get the following error:

In order to function correctly, the PHP XML/DOM extension needs to be available.

I tried to execute

sudo apt-get install php-xml
sudo apt-get install php7.0-xml

but these give me the following error:

php-xml: Depends: php7.1-xml but it is not going to be installed

When I try to install php7.1 from a PPA, I still get issues of dependencies from other PHP modules.

Any ideas how I can get php-xml installed without any dependency issues?

Question

I have a very strange problem.

I use: Ubuntu 16.04.6 LTS I have two running versions of php: php5 and php7.0

I want to install php7.0-xml but when I type in the following command:

apt-get install php7.0-xml

I get this:

Reading package lists... Done
Building dependency tree... 50%
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.0-xml : Depends: php7.0-common (= 7.0.33-1~dotdeb+8.1) but 7.0.33-6+ubuntu14.04.1+deb.sury.org+3 is to be installed
E: Unable to correct problems, you have held broken packages.

I do this:

sudo apt-get install php7.0-common

and I get this:

Reading package lists... Done
Building dependency tree
Reading state information... Done
php7.0-common is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.

I am very confused. How php7.0-common is installed but php7.0-xml does not want to be installed? How can I fix that?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

@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.

How do I enable PHP's XML extension?

Installation of php-xml in Ubuntu.
Step 1: Verify the installation of php-xml on ubuntu. ... .
Step 2: To install php-xml in Ubuntu, update your system packages using the following command. ... .
Step 3: After updating system packages now we install the php-xml using the following command..

How do I know if PHP

You can use the command line switch -m to php to see what modules are installed. $ php -m | head [PHP Modules] bz2 calendar ctype curl date dbase dom exif fileinfo ... You could also use php -i to get phpinfo(); output via the command line which would include this info as well.

How do I enable PHP extensions in Windows?

On Windows, you have two ways to load a PHP extension: either compile it into PHP, or load the DLL. Loading a pre-compiled extension is the easiest and preferred way. To load an extension, you need to have it available as a ". dll" file on your system.

How do I install or enable PHP's DOM extension?

If your PHP version is not the latest, then you can add version in it: # PHP 7.1 sudo apt install php7..
1-xml # PHP 7.2: sudo apt install php7..
2-xml # PHP 7.3 sudo apt install php7..
3-xml # PHP 7.4 sudo apt install php7..
4-xml # PHP 8 sudo apt install php-xml..