Library conflict in Mac OS X

0

I was trying to install the ImageMagick library on Mac OS X Snow Leopard, and first I tried port and, after it failed, homebrew. It updated some dependencies and installed ImageMagick without problems.

So far so good. The problem came when I ran Apache. I got the following error in the system log:

07/04/11 12:55:15   org.apache.httpd[41841] httpd: Syntax error on line 115 of /private/etc/apache2/httpd.conf: Cannot load /opt/local/apache2/modules/libphp5.so into server: dlopen(/opt/local/apache2/modules/libphp5.so, 10): Library not loaded: /opt/local/lib/libpng12.0.dylib\n  Referenced from: /opt/local/apache2/modules/libphp5.so\n  Reason: image not found

I checked the /opt/local/lib and surprise! I don't have the libpng12.0 but the libpng14.0.

So, as far as I can tell, something went wrong installing the ImageMagick library.

Now, I can't find a way to rollback to the previous libraries, other than copying them from the backup. Do you know if is there a way to recover the previous state or reinstall Apache? Or is this just a corrupt state and I must reinstall OS X?

Juan Medín

Posted 2011-04-07T06:03:08.550

Reputation: 173

1The files in /opt/local/ are from MacPorts, but Homebrew (usually) uses /usr/local/. Nothing in the error message refers to either ImageMagick or any Homebrew files (just PHP and libpng from MacPorts; ImageMagick needs libpng, but it also needs lots of other things). How does PHP fit into your goal? You might try rebuilding your MacPorts PHP5 to get it to use the current libpng (probably sudo port update php5), but it seems like you were wanting to move away from MacPorts. Maybe you should build PHP in Homebrew and reconfigure Apache to use it instead. – Chris Johnsen – 2011-04-07T06:41:11.477

Er, the port command should be upgrade, not update, of course. – Chris Johnsen – 2011-04-07T08:43:17.217

Chris, thank your very much for your help. I followed your advise and upgraded PHP via homebrew configuring Apache to use it. It works without problems. I was sweating bullets thinking about reinstalling the whole OS. If you happen to come to Bangkok, I owe you a beer! – Juan Medín – 2011-04-07T23:04:28.117

Answers

1

(Adapted from my comment since it seemed to help to asker.)

The error mentions some MacPorts files, but nothing from Homebrew and nothing about ImageMagick.

Your Apache 2 configuration is trying to load the PHP 5 module built in MacPorts. The problem is that the module was originally built against an older version of libpng (also in MacPorts). The new version of libpng probably came from your aborted attempt to install ImageMagick through MacPorts (libpng is a dependency of ImageMagic and, apparently, also a dependency of the PHP 5 module).

If you want to transition to Homebrew (away from MacPorts), then you will probably want to build the PHP 5 Apache 2 module through Homebrew and update your Apache 2 configuration to use that module instead of the one from MacPorts. You might also want to uninstall MacPorts if you are not using it for anything else.

Alternatively, if you just want to get things working again, you could try upgrading the PHP 5 module in MacPorts. sudo port upgrade php5 will probably do the trick.

Chris Johnsen

Posted 2011-04-07T06:03:08.550

Reputation: 31 786