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.