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:
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.
Permalink for Fixing libxml, php bug and issues with HTML entities; downgrading libxml


Abdurahman said,
November 5, 2008 @ 2:19 pm
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.
Gray said,
November 12, 2008 @ 1:27 am
Worked like a charm! You saved me hours of headaches! Thanks!
max said,
November 12, 2008 @ 6:55 am
I cant update yum.conf! says permission denied even when logged in as root
Codehead said,
November 12, 2008 @ 3:21 pm
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.
Alex said,
January 1, 2009 @ 3:18 pm
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?
Codehead said,
January 1, 2009 @ 8:04 pm
Alex, unfortunately like I said, I can’t help you with that, I hope someone else can help you.