18

How do I enable the DOM extension in my php.ini file? I am running a Wordpress site and getting a message "Please enable the DOM extension in your PHP configuration".

Do I need to edit the wp-config file or php.ini

Steve Bell
  • 209
  • 1
  • 2
  • 9

2 Answers2

21

You need to install php-xml

sudo apt-get install php-xml

or specific version of the extension

sudo apt-get install php7.1-xml

and then according to docs in php.net you have to add

extension=dom.so 

into the php.ini file.

Please note that this extension should be enabled by default. If it's not enabled look for --disable-dom option.

Davit Tovmasyan
  • 3,238
  • 2
  • 20
  • 36
  • 1
    for me I had to `sudo apt-get install php7.1-xml` on ubuntu 16. – Ibrahim.H Nov 08 '19 at 21:54
  • on my CentOS server... i had to add the extension directive as you showed! thank you! but i also had to copy `/opt/remi/php74/root/usr/lib64/php/modules/dom.so` to `/usr/lib64/php/modules/`... the combo is what made it work for me... also... i had to repeat for `simplexml.so` and `xmlwriter.so` to get Authorize.net to work with woocommerce – aequalsb Mar 03 '22 at 16:49
  • 1
    adding to @Ibrahim.H 's comment, you obviously have to look for your php version's extentions, f.e. php8.2-xml ... i think the default php version in the packets points at 7.4.33 - and i'm hoping it changes even that soon. – clockw0rk Jan 23 '23 at 12:55
15

You need to install php-xml.

sudo apt-get install php-xml

Restart your server (here apache).

sudo service apache2 restart

And you can check that everything is OK using :

php -m

Resulting :

[PHP Modules]
...
dom < and other relatives modules as xml, xmlreader, SimpleXML...
...

[Zend Modules]
Zend OPcache
Paul Leclerc
  • 1,117
  • 1
  • 14
  • 18