简体   繁体   中英

How to upgrade libxml to a specific version in Linux for php?

I need to upgrade the libxml library without recompiling php. Tried the following steps:

  1. Download the required version from ftp://xmlsoft.org/libxml2/ (.tar.gz file)
  2. Extracted the .tar.gz file and "cd" command to enter to that folder (eg: libxml2-2.9.5)
  3. Then executed following commands

     ./configure make sudo make install 

All success, but still the php -I | grep libxml php -I | grep libxml is showing the old version only. Please help.

You are mixing between the Library and the PHP Extension, PHP Extension is just a wrapper for the library to be able to use it in your PHP code.

So compiling a library does not means that you can use it as an extension for PHP, You will still need to compile a new version from the extension and use the new version of the library with it.

To upgrade your extension to a specific library version often you will need to compile it from source, the problem with libxml is that it is bundled with PHP by default.

The optional --with-libxml-dir directive is used to specify the location of libxml on the system that PHP is being compiled on, otherwise only the default locations are scanned.

So you may need to recompile a new PHP version from source, and pass the new compiled bin for the new version of libxml to it just like what had been mentioned in the manual :-

./configure .... --with-libxml-dir=/path/to/libxml

Instead of recompiling a new version of PHP and lose all of your current extensions configurations, you may try only recompiling xml extension from source and override the current extension as follows:

clone a new version of PHP:

git clone git@github.com:php/php-src.git
cd php-src/ext/libxml
git checkout YOUR_INSTALLED_PHP_VERSION
phpize
./configure --with-libxml-dir=/path/to/libxml
make
make install

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM