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 PECL package.

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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s