libphp7.so需要12.0.0或更高版本

I have a fresh installation of OSX el capitan 10.11.2 and installed php7 using homebrew.Now getting following error

command

sudo apachectl -e info -k restart

error

httpd: Syntax error on line 171 of /private/etc/apache2/httpd.conf:
 Cannot load /usr/local/opt/php70/libexec/apache2/libphp7.so into server: dlopen(/usr/local/opt/php70/libexec/apache2/libphp7.so, 10):
 Library not loaded: /usr/local/opt/libxml2/lib/libxml2.2.dylib
  Referenced from: /usr/local/opt/php70/libexec/apache2/libphp7.so
  Reason: Incompatible library version: libphp7.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0

I have searched on google but didn't get any specific solution.

PLEASE DO NOT DO THIS!!! YOUR BEST BET IS TO REINSTALL MAC OS X

Alright, I just found a way. It is kinda hacky, but it works.

When trying to run PHP 7, apache checks for libxml2.2.dylib under /usr/lib. To check what version it is currently at, you can run otool -L /usr/lib/libxml2.2.dylib.

That will probably output something like this:

/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)

But Apache and PHP want version 12.0.0, so let's install it through homebrew.

brew install libxml2 libxslt libiconv

This will install libxml to something like /usr/local/Cellar/libxml2/2.9.4/lib. This directory will contain a file called libxml2.2.dylib.

If you run otool -L /usr/local/Cellar/libxml2/2.9.4/lib/libxml2.2.dylib, it will output:

/usr/local/opt/libxml2/lib/libxml2.2.dylib (compatibility version 12.0.0, current version 12.4.0)

So THIS is the version PHP and Apache are looking for. We are going to want to move this file to /usr/lib. But not so fast, we already have a file named libxml2.2.dylib in that folder so lets just add the .bak extension just in case we need it again.

sudo mv /usr/lib/libxml2.2.dylib /usr/lib/libxml2.2.dylib.bak

Now we can move the file that homebrew installed to this directory.

sudo cp /usr/local/Cellar/libxml2/2.9.4/lib/libxml2.2.dylib /usr/lib

That's it! Now you should be able to run sudo apachectl -e info -k restart with no errors and PHP 7 should work correctly.

Install libxml2 with brew,

brew install libxml2

add following line into ~/.bash_profile

export LIBRARY_PATH=/usr/local/Cellar/libxml2/2.9.4/lib/:$LIBRARY_PATH

The version "2.9.4" can be changed to current