Installing Fileinfo using PECL Modules
The PHP Extension Community Library (PECL) is a collection of modules/extensions that you can install to enhance your version of PHP. The categories range wildly from Authentication to Image Handling, and from Encryption to XML. However, installation of the PECL libraries can sometimes be a bit tricky for the beginner. There are two main ways to install the PECL libraries. Note that if you installed PHP from an RPM or similar package, you will also need the PHP-devel package as well.
You can view all the PECL modules available at the PECL website. Some useful modules are:
- ImageMagick
- GDChart More info on using GDChart can be found here.
- ID3
- Mailparse
We will be installing Fileinfo 1.0.4 for this tutorial.
Installation using the PECL binary
If you are using a more recent version of PHP, chances are you have the pecl binary installed as well. As root from the command line, try running ‘pecl’. If found, it will give you a list of options that can be used to compile your extensions. To install Fileinfo, simply type
pecl install fileinfo
This will download the fileinfo source files, phpize the source, and then compile and install the extension.
You will need to activate the extension by editting your php.ini and add:
extension=fileinfo.so
Restarting your webserver should result in PHP starting with the fileinfo extension active and ready for use.
Installing from Source
Some systems don’t have pecl available due to running an older version of PHP. However, you can still install the extension, albeit with a bit more work. The first step is to download the extension, unpack the file, and phpize the contents. You then need to perform a normal configure and make routine to install the module:
wget http://pecl.php.net/get/Fileinfo-1.0.4.tgz
tar -zxf Fileinfo-1.0.4.tgz
cd Fileinfo-1.0.4
phpize
./configure
make
make install
This will install the fileinfo.so module in your php extensions folder. As per above, add this to your php.ini file by adding
extension=fileinfo.so
in the extensions section. It would be wise to check that your php.ini has the correct extensions directory set as well and this is set via the extension_dir directive.
Installing on Windows
Installation of the PECL modules on windows is alot easier, as all the hard work has been done. Simply locate the extension on the PECL Windows page and simply place the dll in your extensions directory. Add the extension to the php.ini file as described above, restart your web server, and you are good to go!









