You Are Here Home > Fixing libxml, php bug and issues with HTML entities;...
Resource Index Web Directory

Fixing libxml, php bug and issues with HTML entities; downgrading libxml

When you parse XML with PHP and libxml 2.7.0, all HTML entities were stripped out and this annoying bug messed up a lot of things and no one seems to care enough to fix this.

This bug is also reported here:
http://bugs.php.net/bug.php?id=45996
http://bugs.typo3.org/view.php?id=9359&nbn=2

From reading these few resources, I knew I had to downgrade to an older version of libxml but since I’m not very good at Linux I had no idea how to.

But I finally figured this out and here is how to do it with WHM/cPanel:

First you will have to install an older version of libxml, I installed libxml 2.6.30.
You will need an SSH client and you will have to login to your server with root, I use Putty:
http://www.chiark.greenend.org.uk/~sgtatham/putty/
Download it, run it, enter the IP address of your server, enter root and enter your password.
Then do:

cd /opt

mkdir libxml

cd libxml

wget http://xmlsoft.org/sources/libxml2-2.6.30.tar.gz

tar xvzf libxml2-2.6.30.tar.gz

cd libxml2-2.6.30

./configure –bindir=/opt/libxml/ –sbindir=/opt/libxml/ –libexecdir=/opt/libxml/ –datadir=/opt/libxml/ –sysconfdir=/opt/libxml/ –sharedstatedir=/opt/libxml/ –libdir=/opt/libxml/ –includedir=/opt/libxml/ –oldincludedir=/opt/libxml/

make && make install

Now you will need to update yum.conf to prevent it from updating libxml back, so edit:
/etc/yum.conf

And find the line that starts with:
exclude=

And add libxml* to the end of it so this line should look something like this:
exclude=apache* bind-chroot courier* dovecot* exim* httpd* mod_ssl* mysql* nsd* php* proftpd* pure-ftpd* spamassassin* squirrelmail* libxml*

Now we will have to let WHM know that we want to compile PHP with this new libxml path so go to:
/var/cpanel/easy/apache/rawopts/

There might be a file there named: “all_php5″ (no quotes) if there is edit it if there is not create it and add these lines to the end of it:
–with-libxml-dir=/opt/libxml
–with-libxml-dir=/opt/libxml/

Now go ahead and build Apache and PHP using:
WHM >> Main >> Software >> Apache Update

You should be all set.

Please note:
1 – Do this on your own risk.
2 – I’m not very good at Linux so please let me know if there is an easier method.
3 – This worked great on my CentOS.
4 – If you have never used WHM’s Apache Update, go ahead and read about it first.

Fixing libxml, php bug and issues with HTML entities; downgrading libxml
Filed under: Annoying Stuff,PHP,Server,Web Development   Posted by: Codehead
Do you have any questions? ask here.




15 Comments »

  1.  

    Hi, Thanks for posting this information.

    At first I think the problem is on wordpress xml-rpc.php file, but I analyzed the code and found nothing.

    I’ve been depressed by trying to fix it myself. But unfortunately this one is not work for me, My blog ran on a free hosting server with limited abilites.

    I’ve copied your article and publish it on my blog. So maybe someone read it and can fix on their own. Don’t worry, I put permalink to your article. :)

    Comment

  2. Gray:
     

    Worked like a charm! You saved me hours of headaches! Thanks!

    Comment

  3. max:
     

    I cant update yum.conf! says permission denied even when logged in as root

    Comment

  4. Codehead:
     

    Max, that’s interesting, like I said, I’m not a Linux guru and don’t really know why that’s happening, you might want to check the other solution which is compiling PHP with libxpat:
    http://blog.code-head.com/fixing-libxml-php-bug-and-issues-with-html-entities-libexpat

    Try it and see if it works for you.

    Comment

  5. Alex:
     

    This is nice for cpanel, but I haven’t cpanel. So everything good, until string /var/cpanel/easy/apache/rawopts/
    I don’t know that is the file “all_php5″, So I don’t understand how I can change:
    –with-libxml-dir=/opt/libxml
    –with-libxml-dir=/opt/libxml/
    And:
    Now go ahead and build Apache and PHP using:
    Main >> Software >> Apache Update
    Could anyone help me?

    Comment

  6. Codehead:
     

    Alex, unfortunately like I said, I can’t help you with that, I hope someone else can help you.

    Comment

  7.  

    Thanks for the guide. I was able to install the older version of Libxml and now Windows Live Writer works perfectly with my WordPress 2.0 blogs

    Comment

  8. Dr.Insano:
     

    Thanks mate, worked like a charm! Gregarius is now working properly on my server again :)

    Now if one day I want to go back to the normal libxml update process would it be enough to remove libxml* from the exclude line in yum.conf ?

    Thanks!

    Comment

  9. Codehead:
     

    Yes, then yum will update it again to latest version the next time it runs. (I think it runs every night)
    Or you can do the same (follow these instructions) with the latest version of libxml.

    I can’t believe no body addressed this issue yet!!!

    Comment

  10.  

    [...] decided to go ahead with option 1. Codehead has a good tutorial on downgrading to libxml v2.6.30 for users running cPanel. Non-cPanel users can check out the tutorial by [...]

    Pingback

  11.  

    Hi

    If someone cannot downgrade libxml2 , There is patch for wordpress.

    see http://blog.hoofoo.net/2009/01/14/wordpress-patch-for-problamatic-libxml2-version/

    Comment

  12.  

    Worked PERFECTLY!

    This thing had me stumped for months!

    Comment

  13. chetas:
     

    Thanks for this!!

    Comment

  14.  

    [...] 解決方法有兩種,其一是把libxml2版本降級,方法可以參考這篇。 [...]

    Pingback

  15. Murad:
     

    hi,
    thank you for your huge efforts.
    can you explain how to downgrade libxml version running on php 5.3 with Apache on Windows platforms ?
    thank you a lot in advance

    Comment

RSS feed for comments on this post. TrackBack URL

Leave a comment