2010-11-22

Enabling internal PHP fileinfo on FreeBSD

In a previous post (Upgrading to PHP 5.3 ...), I mentioned a PECL extension pecl-fileinfo-1.0.4

Apparently, installing that extension was a wrong move. The manual says:
This extension is enabled by default as of PHP 5.3.0. Before this time, fileinfo was a PECL extension but is no longer maintained there. However, versions prior to 5.3+ may use the  discontinued PECL extension. 
 Indeed, the PECL version did not work as expected, so I uninstalled it.


Then I discovered that on FreeBSD the internal version of fileinfo was NOT enabled by default.

Here is the relevant part of Makefile found in /usr/ports/lang/php5:
CONFIGURE_ARGS= \
                --with-layout=GNU \
                --localstatedir=/var \
                --with-config-file-scan-dir=${PREFIX}/etc/php \
                --disable-all \
                --enable-libxml \
                --with-libxml-dir=${LOCALBASE} \
                --with-pcre-regex=${LOCALBASE} \
                --with-zlib-dir=/usr \
                --program-prefix=""

 I created a Makefile.local file with just one line
CONFIGURE_ARGS+=--enable-fileinfo

After rebuilding PHP, this test showed that fileinfo is enabled:
$ php --rf finfo_open
Function [ function finfo_open ] {

  - Parameters [2] {
    Parameter #0 [ $options ]
    Parameter #1 [ $arg ]
  }
}

2 comments:

  1. Thanks for this. The Roundcubemail installer kept giving a warning about not finding fileinfo. Followed your intructions and now this is fixed.

    ReplyDelete
  2. Hi, thanks a lot for this..really helped me..;)

    ReplyDelete