I did a “sudo port upgrade outdated” (using macports) yesterday which completely fecked up my PHP install. I was getting errors from Apache2 saying the php5 module was broken.

So, I re-installed php5 from macports. Or, more accurately, I attempted to. Got this darling error message during configure:

Undefined symbols: “_xmlTextReaderSchemaValidate” “_xmlTextReaderSetup” ld: symbol(s) not found collect2: ld returned 1 exit status

This is a fairly common error with php5 but the php devs are largely ignoring it since it is due to conflicting versions of libxml2 on your system. Basically, the linker seems to be getting confused about which version of libxml2 to use - despite it being specifically specified with the “–with-libxml-dir=/opt/local” specified in the Portfile and trying to use various ones around the place left by other installs (such as Gnome or OSX itself instead).

I fixed it, after over 24 hours of trying every thing I could think of including scrapping my entire /opt/local hierarchy.

The solution, at least in my case, turned out to be quite simple: I installed the latest version of libxml2 into the standard locations (in addition to the libxml2 installed by macports as a dependency of php5).

I downloaded libxml2 manually and did a “./configure && make && sudo make install”. I then tried my php5 macports install again (“sudo port clean php5 && sudo port install php5 +apache2 +mysql5 +imap”) and voila! Working php5 installation again.