2026年11月14日
2026年11月14日
PHP DOM Extension Disabled: Fix the WordPress Site Health Warning
This article is a localized edition of the Japanese original. Read the Japanese original
PHP's DOM extension (dom) lets PHP read and write HTML and XML through the DOMDocument class. WordPress core runs without DOM, but some plugins and themes that process HTML rely on it.
When the DOM extension is missing, you usually notice it in one of two ways:
- Tools → Site Health shows "One or more recommended modules are missing", and when you open it, it says "The optional module, dom, is not installed, or has been disabled."
- The screen stops working, for example right after activating a plugin, and the error log contains a fatal error like this
PHP Fatal error: Uncaught Error: Class "DOMDocument" not found in /var/www/html/wp-content/plugins/...
The DOM extension is a standard part of PHP; if you build PHP yourself, it is enabled unless you pass --disable-dom (PHP manual: DOM installation). When it is disabled, the usual reason is that PHP was installed from Linux packages without the XML package.
First, check whether DOM works in your web server’s PHP
The command-line php and the PHP your web server runs (PHP-FPM or the Apache module) can have different configurations. Check both.
Check in Site Health
Open Tools → Site Health → Status. If dom is not listed under "One or more recommended modules are missing," DOM is enabled in your web server's PHP. WordPress decides this by checking whether the DOMNode class exists (class-wp-site-health.php).
Check from the command line
If you can log in to the server over SSH, check with the following. If dom is printed, DOM is enabled in the command-line PHP.
php -m | grep -i '^dom$'
php --ini # which configuration files are loaded
Fix it on Ubuntu and Debian
On Ubuntu and Debian, the DOM extension is included in the phpX.Y-xml package. This package provides the DOM, SimpleXML, XML, and XSL modules (Debian package php8.4-xml). These steps were tested on Ubuntu 24.04 with PHP 8.3 (as of November 2026).
The steps are as follows. Replace 8.3 with the version shown by php -v.
# 1. Check the running PHP version
php -v
# 2. Install the xml package for the same version
sudo apt update
sudo apt install php8.3-xml
# 3. If the package is installed but the module is disabled, re-enable it
sudo phpenmod dom
# 4. Restart the web server's PHP (only the one you use)
sudo systemctl restart php8.3-fpm # PHP-FPM (Nginx, or Apache + PHP-FPM)
sudo systemctl restart apache2 # Apache module (mod_php)
# 5. Check that it is enabled
php -m | grep -i '^dom$'
Installing the package creates /etc/php/8.3/mods-available/dom.ini (containing extension=dom.so) and enables it as 20-dom.ini in the conf.d directories for CLI, FPM, and so on. If the package is installed but DOM is disabled, it was turned off with phpdismod dom. Finally, check Site Health as well.
Note: if you disable only dom, modules that depend on DOM, such as xmlreader and xsl, also fail to load, and PHP prints an undefined symbol: dom_node_class_entry warning at startup. Avoid disabling DOM on its own.
Fix it on AlmaLinux and Rocky Linux (RHEL family)
On the RHEL family, the DOM extension is also included in the php-xml package, which creates /etc/php.d/20-dom.ini when installed (verified on AlmaLinux 9, as of November 2026).
sudo dnf install php-xml
sudo systemctl restart php-fpm # for PHP-FPM
sudo systemctl restart httpd # for Apache
php -m | grep -i '^dom$'
If you installed several PHP versions from a third-party repository, install the xml package that matches the PHP your web server uses, and restart that PHP-FPM.
About extension=dom in php.ini
You'll find instructions online that say "remove the semicolon from ;extension=dom in php.ini," but with packaged PHP on Linux, DOM is loaded not from php.ini but from an additional configuration file (conf.d/20-dom.ini on Ubuntu and Debian, /etc/php.d/20-dom.ini on the RHEL family). The "Scan for additional .ini files in" line of php --ini shows which directory is read. Before editing php.ini, check whether the package is installed.
The official Docker wordpress image includes the DOM extension out of the box.
On shared hosting
On shared hosting, users usually can't add PHP extensions themselves.
- If your hosting control panel lets you switch PHP versions, switching to another version may change which modules are available. For precautions when switching, see How to switch the PHP version for WordPress.
- If
domis still unavailable, ask your hosting provider's support "whether the PHP DOM extension (dom) can be enabled."
What to check after the fix
- That
domno longer appears under "One or more recommended modules are missing" in Site Health. If other modules are listed, also see How to deal with Site Health warnings. - That the plugin that stopped working can be activated, and
Class "DOMDocument" not foundno longer appears in the error log.
FAQ
Does WordPress work without the DOM extension?
WordPress core works. Site Health also treats DOM as "recommended" (optional), not "required." However, plugins and themes that use DOM stop with a fatal error, so it is safer to keep it enabled.
The command line shows dom, but Site Health says it’s disabled
The command-line PHP and the web server's PHP are different versions or read different configurations. Install the xml package that matches the PHP-FPM version your web server uses (for example, php8.3-fpm) and restart that service.
Summary
- Without the DOM extension, you get the Site Health recommended-module warning or a plugin's
Class "DOMDocument" not founderror. - Install
phpX.Y-xmlon Ubuntu and Debian orphp-xmlon the RHEL family, then restart PHP-FPM or Apache. - On shared hosting, try switching the PHP version; if that doesn't help, contact your hosting provider.
Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)