Friday 8 March 2013

Enable php fileinfo() on server


If we have the pecl binary installed then from the command line, we can run pecl, it will give a list of options that can be used to compile your extensions. Also we can install fileinfo with the following command:
# pecl install fileinfo

This will download the fileinfo source files, phpize the source, and then compile and install the extension. But we need to add "extension=fileinfo.so" in php.ini file and restart apache. Restarting apache will help PHP starting with the fileinfo extension active and ready for use.

If that above doesn't work then go for source install
# 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

After running the above commands you need to edit php.ini and add the following line.
extension=fileinfo.so

Restart apache service.
# /etc/init.d/httpd restart

We can verify the installation by phpinfo page.