Installing a single php extension without recompiling PHP is never been a difficult job but most of the people doesn’t know it which leads to re-compile whole php.. In this article i will explain how can you add new php extension without recompiling whole php.
In our example, i will tell you how can you add iconv php extension without recompiling PHP.
A sample error for iconv php extension which was not installed
Fatal error: Call to undefined function iconv() in /some/path/file.php line 12
iconv php extension necessary configuration & compilation :
View current php version
PHP 5.2.13 (cli) (built: Jun 23 2010 04:49:30)
Copyright (c) 1997-2010 The PHP Group
Downloading the same php version source code from php.net
tar -jxf php-5.2.13.tar.bz2
Prepare php extension to compile it.
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
You can can see iconv php extension is installed under php extensions directory:
Enable iconv PHP extension in php.ini
echo "extension=iconv.so" >> /usr/local/lib/php.ini
Verify iconv :
php -i | grep -i "iconv support"
iconv support => enabled