How do I enable the DOM extension in the php.ini

How do I enable the DOM extension in the php.ini

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

Enabling the DOM Extension in PHP Configuration

When you encounter the error message "Please enable the DOM extension in your PHP configuration" on a WordPress site, the immediate instinct is often to modify wp-config.php. However, this approach addresses the wrong layer of the stack. The DOM extension is a core PHP component that must be compiled into the interpreter or loaded as an extension file; it does not function via WordPress constants or plugin settings.

To resolve this, you need to inspect your server's PHP environment directly. The primary configuration file for global settings is php.ini. However, in modern hosting environments—particularly with shared hosting or managed platforms like LaravelCompany—the location and method of enabling extensions can vary significantly depending on how the PHP binary was built and deployed.

Understanding Extension Loading Mechanisms

PHP loads extensions based on specific directives defined in the active configuration file. Before editing any files, you must identify which php.ini is actually being used by your web server. You can verify this by creating a simple info.php file containing <?php phpinfo(); ?> and accessing it via your browser. Look for the "Configuration File (php.ini) Path" directive to confirm the exact location.

If the extension is not listed in the output, you have two main paths forward depending on your hosting setup:

  1. Static Compilation: If PHP was compiled statically with the DOM support (-DOM flag used during build), no configuration change is required. The issue might instead stem from a mismatch between the PHP version running WordPress and the expected features.
  2. Dynamic Loading: In this scenario, you need to ensure the extension file is present in the extension_dir (usually found in php.ini) and that the specific directive extension=dom is uncommented or added.

Editing php.ini Directly

On VPS environments or local setups where you have full root access, locating the active php.ini is straightforward. Open the file using a text editor and search for lines starting with ;extension=dom or extension=dom. Remove the leading semicolon to uncomment the line:

extension=dom

If the line does not exist entirely, append it at the end of the file. However, simply adding the line is not always sufficient. The extension files themselves (often .so on Linux or .dll on Windows) must reside in the directory specified by the extension_dir directive within that same configuration file. If the physical extension file is missing from the expected path, PHP cannot load it regardless of the configuration setting.

The Shared Hosting Constraint

This is where many developers stumble. On shared hosting plans, you typically do not have direct access to the server's php.ini. Consequently, editing the global configuration file is impossible without root privileges. In these environments, the hosting provider manages the PHP core and extensions.

If your WordPress admin dashboard displays the DOM error, it usually indicates that the hosting environment has not enabled the extension for your specific account, or they are running a stripped-down version of PHP (common with older versions like PHP 7.4 default configurations on some hosts) that lacks the DOM module entirely.

In this case, the correct procedure is to contact your hosting support team. Provide them with the error message and request that they enable the DOM extension for your domain. They may need to rebuild the PHP environment or simply toggle a flag in their control panel (such as cPanel's "Select PHP versions" tool) if multiple PHP versions are available.

Alternative Approaches via .user.ini or .htaccess

Some modern PHP distributions, particularly those using OpCache or specific SAPI handlers (like FPM), respect .user.ini files placed in the root of your WordPress installation. If your host supports this, you can attempt to add the directive there:

[PHP]
extension=dom

Alternatively, if you are using Apache with mod_php, you might try adding the directive to an .htaccess file, though this is deprecated and often ignored in favor of php.ini settings:

php_flag extension.dom on

Note that this method relies on AllowOverride All being enabled in your .htaccess or virtual host configuration. If you lack write access to these files, direct editing is not an option.

Verification and Next Steps

After making changes—whether by editing a local php.ini, uploading a .user.ini, or waiting for support confirmation—you must restart the PHP-FPM service or reload Apache/Nginx to apply the new configuration. On shared hosting, this happens automatically once the provider applies the change.

Once restarted, access your site again. The error should vanish if the DOM extension is successfully loaded. If you still see the error, check phpinfo() again to confirm the "DOM" section appears in the output.

It is also worth noting that some WordPress themes or plugins explicitly require the DOM extension for parsing XML feeds or handling specific HTML sanitization tasks. If you cannot enable the extension due to hosting restrictions, you may need to seek an alternative theme or plugin that relies on different libraries, such as using cURL or native PHP string functions instead of DOMDocument.

Our network