How to add PHP DOMDocument extension to httpd in CentOS 7?

Just migrated a PHP site to a new server. However, in /var/log/httpd/error_log, there are errors like

[:error] [pid 2810] [client 61.92.242.24:43372] PHP Fatal error: Class ‘DOMDocument’ not found in /var/www/…/some.php on line 16

How to add PHP DOMDocument extension to httpd in CentOS 7?

You need to install the package php-xml to have DOMCoument support to PHP:

# yum install php-xml

You may need to restart apache/httpd (# apachectl restart).

The package contains:

$ rpm -ql php-xml
/etc/php.d/dom.ini
/etc/php.d/wddx.ini
/etc/php.d/xmlreader.ini
/etc/php.d/xmlwriter.ini
/etc/php.d/xsl.ini
/usr/lib64/php/modules/dom.so
/usr/lib64/php/modules/wddx.so
/usr/lib64/php/modules/xmlreader.so
/usr/lib64/php/modules/xmlwriter.so
/usr/lib64/php/modules/xsl.so

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *