Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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/ into server: dlopen(/opt/local/apache2/modules/, 10): Library not loaded: /opt/local/lib/libpng12.0.dylib\n  Referenced from: /opt/local/apache2/modules/\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?

share|improve this question

migrated from Apr 7 '11 at 7:32

This question came from our site for system and network administrators.

The 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 Apr 7 '11 at 6:41
Er, the port command should be upgrade, not update, of course. – Chris Johnsen Apr 7 '11 at 8:43
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 Apr 7 '11 at 23:04
up vote 1 down vote accepted

(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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .