Installing PECL Modules

January 19th, 2006

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:

We will be installing Fileinfo 1.0.3 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.3.tgz
tar -zxf Fileinfo-1.0.3.tgz
cd Fileinfo-1.0.3
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!


 Add to del.icio.us    Digg this    Technorati

Related Posts:

Entry Filed under: PHP

6 Comments Add your own

  • 1. Rien  |  May 10th, 2007 at 5:59 am

    What I can do possible wrong?

    Installing on Windows of the PECL module fileinfo.dll
    …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!

    I did all of that…
    1) added this line in my php.ini extension=fileinfo.dll
    2) copied the dll file into my php ext folder
    3) restarted my apache webserver on localhost

    Result:
    Fatal error: Call to undefined function mime_content_type() in D:websites2006-apeironstetst.php on line 2

  • 2. amimusa  |  May 18th, 2007 at 2:40 pm

    Solution, don't use Windows

  • 3. Jeremiah  |  July 25th, 2007 at 5:29 am

    check in the php.ini
    extension=php_mime_magic.dll
    also
    I suppose you download appropriate file for PHP? ;)
    I use php 5.1.6 add php_fileinfo.dll
    php-5.1.6 (5_1) 60 269 Compile 2007-07-24 15:12:59
    fine. Even I use Windows ;)

  • 4. Fredy  |  October 31st, 2007 at 12:15 am

    I have instaled in Red Hat AS4 and all works great!

    thank's for the how to

  • 5. Lab 3: Meinen Kampf (mit &hellip  |  November 3rd, 2007 at 4:11 am

    […] http://www.jellyandcustard.com/2006/01/19/installing-pecl-modules/ […]

  • 6. Installing PECL Extension&hellip  |  March 26th, 2008 at 8:08 pm

    […] Great guide here. What is the difference then all the other guides out there? Most other guides fail to mention this portion of the installation process: You will need to activate the extension by editting your php.ini and add: […]

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

January 2006
M T W T F S S
« Dec   Feb »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Most Recent Posts