How7o
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: How to Enable the PHP DOM Extension
Share
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Free Laravel, PHP, WordPress & Server Tutorials > Server Management > How to Enable the PHP DOM Extension
Server Management

How to Enable the PHP DOM Extension

how7o
By how7o
Last updated: May 22, 2026
5 Min Read
Enable the PHP DOM extension on a Linux server
SHARE

To enable the PHP DOM extension, install the bundled php-xml package (on Debian/Ubuntu) and restart the PHP process that serves your site. If the extension is installed but disabled, uncomment extension=dom in php.ini (or the matching file under conf.d/). After that, php -m should list dom among the loaded modules.

Contents
  • Check whether DOM is already loaded
  • Install the extension (Ubuntu / Debian)
  • Install on RHEL / Alma / Rocky
  • Enable it if it’s installed but disabled
  • Restart PHP
  • Verify
  • Frequently asked questions
  • Related guides
  • References

Last verified: 2026-05-17 on Ubuntu 22.04 with PHP 8.1 and 8.3. Originally published 2023-02-24, rewritten and updated 2026-05-17.

Check whether DOM is already loaded

php -m | grep -i dom

If you see dom in the output, the extension is loaded for the CLI. If nothing prints, it’s either not installed or installed-but-disabled.

Enable PHP DOM extension — install php-xml, restart FPM or Apache, verify with php -m

Install the extension (Ubuntu / Debian)

# Generic — installs DOM for the default PHP
sudo apt-get install php-xml

# Pinned to a minor version
sudo apt-get install php8.1-xml
sudo apt-get install php8.3-xml

The php-xml meta-package pulls in DOM, SimpleXML, XMLReader, XMLWriter, and XSL — all the XML-family extensions. If you only want DOM, the package is still the same bundle.

Install on RHEL / Alma / Rocky

sudo dnf install php-xml
# or, with Remi's repo
sudo dnf install php81-php-xml

Enable it if it’s installed but disabled

Find which ini file controls DOM:

php --ini
# Loaded Configuration File:         /etc/php/8.1/cli/php.ini
# Scan for additional .ini files in: /etc/php/8.1/cli/conf.d

On Debian/Ubuntu, the per-extension files live under /etc/php/{ver}/mods-available/ and are enabled by phpenmod:

sudo phpenmod dom
# To verify the symlinks:
ls -l /etc/php/8.1/fpm/conf.d/ | grep dom

On distros without phpenmod, edit the relevant ini file directly. Find the line ;extension=dom (or ;extension=dom.so on older PHP) and remove the leading ; to uncomment it. Save and restart PHP.

Restart PHP

# PHP-FPM (Nginx, or Apache via proxy_fcgi) — most common stack
sudo systemctl restart php8.1-fpm

# Or mod_php (Apache loads PHP in-process)
sudo systemctl restart apache2

Verify

php -m
# [PHP Modules]
# ...
# dom
# ...
# [Zend Modules]
# Zend OPcache

If php -m shows dom but WordPress still complains, the web PHP is loading a different config. Run phpinfo() from a script in your document root to confirm what the web PHP sees, then check that the corresponding FPM pool (or Apache config) is the one you restarted.

Frequently asked questions

Why does the DOM extension ship in the php-xml package?

Historically the DOM, SimpleXML, and XMLReader/XMLWriter extensions are all bundled into a single Debian/Ubuntu package called php-xml (and php8.x-xml per minor release). Installing it installs all of them at once. RHEL-family distributions sometimes split php-dom separately, but on most modern stacks php-xml is what you want.

Where is the right php.ini when there are several?

Run php --ini — it prints “Loaded Configuration File” and the directory of additional .ini files (often conf.d/ or mods-available/). On most distros, individual extensions live in their own conf.d/20-dom.ini rather than the main php.ini, and you toggle them by enabling/disabling that file. The CLI and FPM php.ini can also differ — check both with php --ini and php-fpm -i | grep 'Loaded Configuration'.

Do I need to restart Apache or just PHP-FPM?

On mod_php stacks (Apache loads PHP as a module), restart Apache: sudo systemctl restart apache2. On PHP-FPM stacks (Nginx or Apache with proxy_fcgi), restart FPM: sudo systemctl restart php8.x-fpm. If you’re not sure which you’re on, php -v alone won’t tell you — check what’s actually serving requests with ps aux | grep -E 'php-fpm|httpd|apache'.

How can I confirm the DOM extension is loaded without restarting?

From the command line, php -m | grep -i dom shows the CLI module list. To confirm what your web PHP sees, drop a <?php phpinfo(); ?> into a temp file under your document root and hit it from the browser — search for “dom” in the output. Remove the file when done; phpinfo leaks server details.

Related guides

  • How to Install PHP on Ubuntu
  • How to Display PHP Errors
  • How to Create a Folder If It Does Not Exist in PHP

References

PHP DOM manual: php.net/manual/en/book.dom.php. PHP extension installation on Debian/Ubuntu: wiki.debian.org/PHP. phpenmod: man phpenmod on any Debian-family system.

TAGGED:configurationphpUbuntu

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article Duplicate a div into another div with jQuery clone How to Duplicate a DIV into Another DIV with jQuery
Next Article Extract a .tar.gz archive in PHP with PharData How to Extract a .tar.gz Archive in PHP
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow
Most Popular
Run Laravel queue workers with Supervisor
How to Run Laravel Queue Workers in Production with Supervisor
May 23, 2026
Nginx as a reverse proxy for a Node.js app on Ubuntu
How to Set Up Nginx as a Reverse Proxy for Node.js on Ubuntu
May 23, 2026
Install and configure Redis on Ubuntu for Laravel and WordPress
How to Install and Configure Redis on Ubuntu (for Laravel & WordPress)
May 23, 2026
Harden a fresh Ubuntu VPS with UFW, Fail2Ban, and SSH key auth
How to Harden a Fresh Ubuntu VPS: UFW + Fail2Ban + SSH Key Auth
May 23, 2026
Set up Let's Encrypt SSL with Certbot on Ubuntu
How to Set Up Let’s Encrypt SSL with Certbot on Ubuntu (Apache & Nginx)
May 23, 2026

You Might Also Like

Laravel Eloquent orderBy — code snippet sorting posts by id descending with arrow icons
Web Development

How to Use orderBy in Laravel Eloquent (with Examples)

6 Min Read
Get the current year in PHP, Laravel and JavaScript
Web Development

How to Get the Current Year in PHP (and Laravel and JS)

4 Min Read
Include Composer packages in plain PHP projects
Web Development

How to Include Composer Packages in Plain PHP Projects (Autoload + Example)

5 Min Read
Laravel Eloquent records today — Carbon today helper and whereDate illustration
Web Development

How to Get Records Created Today in Laravel

6 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Tools

  • Age Calculator
  • Word Counter
  • Image Upscaler
  • Password Generator
  • QR Code Generator
  • See all tools→

Pranks

  • Fake Blue Screen Prank
  • Hacker Typer
  • Fake iMessage Generator
  • Windows XP Crash Prank
  • Windows 11 Update Prank
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?