15

When I run this command php -v
this error comes up:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/dom.so' - /usr/lib/php/20160303/dom.so: undefined symbol: php_libxml_node_free_list in Unknown on line 0

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/xmlreader.so' - /usr/lib/php/20160303/xmlreader.so: undefined symbol: dom_node_class_entry in Unknown on line 0

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/xsl.so' - /usr/lib/php/20160303/xsl.so: undefined symbol: dom_node_class_entry in Unknown on line 0
PHP 7.1.5-1+deb.sury.org~trusty+2 (cli) (built: May 22 2017 13:39:01) ( NTS )

Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.7-1+ubuntu14.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies

4
  • Anybody can help me?
    – Scott Wang
    Jul 16, 2017 at 19:38
  • I think the error message explains itself, it cant find the dynamic libraries it is expecting at the locations it is telling you about. First thing to do would be to check they exist Jul 16, 2017 at 19:40
  • But I don't know how to locate the xmlreader.so, @PeterFeatherstone
    – Scott Wang
    Jul 16, 2017 at 19:57
  • The path is given to you... Jul 16, 2017 at 20:10

5 Answers 5

64

Safe solution is to reinstall all php7 related packages.

You can do it by simply entering this command to console:

sudo apt-get install --reinstall `dpkg -l | grep 'ii  php7' | awk '{ printf($2" "); next}'`

This solution will keep your configuration unchanged

5
  • Thankfully, it worked for my ubuntu 14.04, but I have the same problem with my mac......
    – Scott Wang
    Jul 21, 2017 at 7:44
  • Thank you. It worked on ubuntu 14.04 in the 2015 directory. Jul 27, 2017 at 19:52
  • 1
    Working! but in case I will need to replace php7 to php7.1 Aug 4, 2017 at 6:18
  • 1
    Don't forget to change the "grep" part if you want to focus on the 7.1 version only (you may have both 7.0 and 7.1 installed packages...)
    – niconoe
    Aug 7, 2017 at 8:45
  • this worked for me. somehow things broke after an upgrade to php7.2 but this fixed it. Aug 29, 2018 at 20:21
8

(In ubuntu 14.04 or above)

sudo apt-get install libapache2-mod-php7.0 libphp7.0-embed libssl-dev openssl php7.0-cgi php7.0-cli php7.0-common php7.0-dev php7.0-fpm php7.0-phpdbg

reference:

https://gnh1201.wordpress.com/2017/07/24/php-7-0-undefined-symbol-php_libxml_node_free_list/

5

I found almost the same problem with xml after linux update (and PHP 7.0 -> 7.1 with it).

The solution for me was pretty simple:

sudo apt install php7.1-xml
0

I experienced the same errors. The reportedly missing files were present, the file permissions looked ok to me, and PHP was executed using the correct user and group.

For me it helped, to remove all PHP packages and do a fresh start.

  1. The following command should remove all PHP packages on a Debian/Ubuntu systems (including the PHP config - make a backup before):

    sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
    

    Source: https://askubuntu.com/a/187278

  2. Check if PHP was removed:

    php -v
    

    This should return something like "command not found: php".

  3. Then, install PHP again, e.g.:

    sudo apt-get install php7.1 php7.1-xml php7.1-fpm php7.1-json
    
2
  • 1
    Your solution will remove package configuration. Check my answer for fix without deleting configuration.
    – Fiil
    Jul 20, 2017 at 10:01
  • Thanks for the comment. Depending on the configuration, starting with a fresh one, might be a good idea (or not). I added a warning though! :)
    – Icarus
    Jul 20, 2017 at 11:38
-1

In my case some php packages were not upgraded, so I simply had to perform a dist-upgrade:

sudo apt-get dist-upgrade

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.