Click here to Skip to main content
15,888,113 members
Articles / Programming Languages / PHP
Technical Blog

Hack around with PECL libs for PHP in Lubuntu

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
24 May 2013CPOL2 min read 6.6K  
Hack around with PECL libs for PHP in Lubuntu.

peclsmall

From my very childhood I dreamed about many things to be when I am grownup – from a soldier to sailor, from a pilot to postman, from engineer to innovator but, by any chance never dreamed about a writer. Now I am writing.

Like the same nature of your life you may need certain things you never have thought about. As I needed to install the PECL library for PHP in an Ubuntu machine. Well how to do it, is pretty much straight forward steps and not much interesting – what is interesting is my experience with its installation.

Well I needed a function in PHP called ‘id3_get_tag’ which needs a package id3. This package can be found in a repository called PECL. This id3 package is maintained by Stephan Schmidt and Carsten Lucke. Thanks to them on behalf of me. I and many others like me are always thankful to those guys who are maintaining this kind of open source libraries.

However you can download the id3 extension of PECL package from here. Download it to your Ubuntu machine – for me it was a lubuntu machine. Unzip it. Follow this commands

cd ./Downloads/Temp/ id3-0.2
phpize
./configure
make

Ignore the errors of the phpize command. The phpize command is used to prepare the build environment for a PHP extension. In our case id3 extension for the PECL package. After the make you will find a shared library called id3.so possibly in the modules directory.

Now all you will have to do is place this library is a place where php5 can reach it. Now to find out this place you will have to hack a little bit. Find this kind of other library in the php.ini or mysql.ini or gd.ini. For example

In the gd.ini you will find

extension=gd.so

In the mysql.ini you’ll find

extension=mysql.so

Next we will have to find the location of these files with command

find / -type f –name ‘gd.so’
find / -type f –name ‘mysql.so’

If you compare the paths you will be able to see a common location for these two files (../php5/…/gd.so). Bang!! That’s the location from where the php5 is loading them. For our case the location was /usr/lib/php5/20090626+lfs.

Now all we have to do is copy our shared library id3.so to that location. Then create a id3.ini file in the location /etc/php5/conf.d. Write ‘extension=id3.so’ in the file.

cd  /etc/php5/conf.d

sudo echo “extension=id3.so” > id3.ini

Restart the apache.

sudo /etc/init.d/apache2 restart

Now test a page with function ‘id3_get_tag’, it will execute successfully. Walla!! You have successfully installed the id3 library from the PECL package.

You can absolutely do the same for the other libraries in the PECL package.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Sweden Sweden
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --