Magento 2 – Uncaught Error: Class ‘DOMDocument’

Per [aMiSTACX] using PHP 7.1 you may get an error like this after a system update/upgrade:

Uncaught Error: Class ‘DOMDocument’ not found in /var/www/magento/vendor/magento/framework/Config/Dom.php:384…

The browser will report a 500 error, but the Apache logs will show more details.

The fix is really simple. From CLI:

sudo a2dismod php7.2

sudo service apache2 restart

Note: Make sure all versions of php are disabled:

sudo a2dismod php7.1
sudo a2dismod php7.2
sudo a2dismod php7.3
sudo a2dismod php7.4

clear browser cache

Leave a comment