2

I have a server that has PHP 7.4.3 installed, but it doesn't load PHP-DOM.

It's not listed in php -m or php -i, nor when I load PHP on a page.

Here's what I tried so far:

  1. Ran sudo apt-get install php-xml several times, it installs without a problem and shows the newest version is already installed.

  2. Ran sudo apt-get install php7.4-xml, it's unable to locate the package.

  3. Added extension=dom.so to php.ini and checked for the --disable-dom flag (not found).

  4. Restarted apache multiple times throughout this process.

How can I enable the PHP DOM extension?

5

1 Answer 1

1

Run this command: php7.4 -m. Also make sure there is a file dom.ini in this folder: /etc/php/7.4/mods-available/ When on linux to enable the extenstion you should not edit the php.ini but use the command phpenmod

Also try installing PHP from ppa:ondrej/php.

For detailed steps read the comment by karel

1
  • 1
    php7.4 -m displays the loaded PHP modules, including extensions like dom. If dom is not listed in php7.4 -m 1. This suggests the DOM extension is not installed. You can install with sudo apt install php7.4-xml. 2. Once installed, you might still need to enable the extension in your php.ini file. Look for the extension=dom.so line and remove the leading ; if it's present. 3. Restart your server to enable the changes.
    – karel
    Commented Dec 15, 2023 at 5:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .