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
  • check this serverfault.com/questions/66189/… Commented Mar 18, 2023 at 10:53
  • stackoverflow.com/questions/44045478/… Commented Mar 18, 2023 at 10:53
  • Thanks @BlockchainOffice, I've tried those but it does not work Commented Mar 18, 2023 at 11:16
  • can you try install php7.0-xml & php7.0-mbstring instead of php-xml and check if this works? Commented Mar 18, 2023 at 11:20
  • Thank you. Tried that, still does not work :( Commented Mar 18, 2023 at 17:31

2 Answers 2

2

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. Commented Dec 15, 2023 at 5:34
0

Most likely you have multiple php versions installed.

  1. Make sure which version you are using: php -v

  2. Run the installer of the particular verison: sudo apt-get install php8.4-xml

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.