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
Laravel Eloquent ORM — a model class mapping to a database table with query methods
Laravel Eloquent ORM: The Complete Guide to Querying Your Database
June 16, 2026
Set vi as the default editor in Ubuntu — a terminal opening the vim editor
How to Set vi (Vim) as the Default Editor in Ubuntu
June 8, 2026
rsync says ALL DONE but files are missing — a terminal showing ALL DONE next to an empty folder
rsync Says “ALL DONE” but Files Are Missing: How to Verify
June 8, 2026
Migrate a website to a new server with rsync — files copying from an old server to a new one over SSH
How to Migrate a Website to a New Server With rsync
June 8, 2026
Bun runtime — faster JS toolkit replacing npm in Laravel projects
How to Install Bun Runtime on Ubuntu (And Use It in a Laravel Project)
May 24, 2026

You Might Also Like

Migrating files from cPanel to aaPanel using rsync
Server Management

cPanel to aaPanel Migration with rsync: Fix Permissions, SSH Port, and CSF Firewall

6 Min Read
MySQL connect remote from Ubuntu — mysql-client + mysql -h host
Server Management

How to Connect to a Remote MySQL Database from Ubuntu

7 Min Read
Laravel unknown column CONCAT fix — DB::raw and selectRaw bypass identifier escaping
Web Development

How to Fix “Unknown column ‘CONCAT'” in Laravel

8 Min Read
Install Laravel on Ubuntu — terminal with composer create-project command and Laravel red-pillar icon
Web Development

How to Install Laravel on Ubuntu: Step-by-Step Guide

9 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?