Categories
php

How to Install Php Extension

The easiest way to install php extension is using pecl.

To install you have to run

pecl install extension_name

But if you have the sources of the php extension then.

cd extension_name_folder
phpize
./configure
make
make install

if you have php installed in another location. Lets assume php is installed in /opt/php
To install the extension you have to do is first download the extension and then unzip it and run the phpize and make and make install. Example commands to run

pecl download extenstion_name # you will see a .tgz / .zip / .tar.gz file
unzip  extension_name.zip # unzip  / untar it using tar xvfz extension_name.tar.gz
cd extension_name_folder
export PHP_PREFIX="/opt/php"
$PHP_PREFIX/bin/phpize
./configure --with-php-config=$PHP_PREFIX/bin/php-config
make
make install

Then to enable you have to add in your php.ini file

extension=extension_name.so