How To: Installing the fileinfo pecl extension to Mac OS X Leopard
Many people had problems installing the fileinfo pecl extension into Mac OS X. I believe this is probably a problem in a lot of other packages as well. From a search through the net I cannot find any workaround but I’ve come up with me own.
First of all I need to state that I’ve installed Apache and PHP via MacPorts. PHP is configured with Pear.
Once you’ve got that set up.
Do:
sudo pecl install fileinfo
At which point you’ll get an error saying something about libmagic doesn’t exist etc…
First of all. If you haven’t installed libmagic yet. Do:
sudo port install file
If you couldn’t install file and it was about it couldn’t fetch the file file… >.> then it’s probably about this: http://trac.macports.org/ticket/15831
Anyway, once you’ve got file installed via macport, we’ll go back to that error message about libmagic.
To address it, you should find the files under /private/tmp/pear/download/Fileinfo
what we’ll do essentially is now to just change the configure script. By:
mate /private/tmp/pear/download/Fileinfo*/config.m4
Once you’ve opened it up in textmate (or an editor of your choice) do a search for “SEARCH_PATH=”
and add in /opt/local into the mix. At the time of writing with Fileinfo v1.0.4 it is on line 8 and you should end up with: SEARCH_PATH=”/opt/local /usr/local /usr /usr/share/file”
Save the file. Now we’ll install PECL modules manually.
To do that, simply follow this:
http://php.net/manual/en/install.pecl.phpize.php
Hope this will help someone. (if anyone ever finds my blog =])
edit: Oh, and when you start using it. You may have to manually specify where the magic database file is. I had to and mine was at : ‘/usr/share/file/magic.mime’ OR you can choose to rebuild it to your chosen path by editing config.m4 and find: MAGIC_MIME_DIRS and add in your chosen magic database file’s path to the front of the mix.
This is how mine looks like:
MAGIC_MIME_DIRS="/usr/share/file /opt/local/share/file /usr/local/share/file /usr/share/misc/file /etc /usr/share/misc"
MAGIC_MIME_FILENAMES="magic.mime magic"
Once you’ve rebuilt it then restart apache and it’ll work. (remeber to do a clean rebuild!)


