I just moved my WordPress website to a new server, and now I see a message that says, ‘Please enable the DOM extension in your PHP configuration.’ After some research, I found that the DOM extension needs to be enabled in my php.ini file. However, I’m unsure where to make the changes. How can I enable the DOM extension in php.ini?
By default, the DOM extension should already be enabled in PHP. You can check if the extension exists by running the command in your terminal.
If the extension is missing, it may not be installed on your server. You can install it by running the command:
sudo apt-get install php-xml
or specific version of the extension
sudo apt-get install php8.1-xml
If the extension is still not enabled, you can enable it by editing your PHP configuration file (php.ini).
- Search for the following line in the file: “;extension=dom.so”.
- Remove the semicolon “;” at the beginning of the line to uncomment it,
- Or add “extension=dom.so” if it’s not already there.
- Save the file and restart your web server (e.g. Apache, Nginx) and PHP.
After completing these steps, you can run the command
php -m again to confirm that the DOM extension is enabled, and the output should look like this.