*** last modified on 12 January, 2018 ***
Installation of PECL extensions on a server with Directadmin is rather simple, but at the same time many users are confused with it. Here is a guide on how to make it in a easy way.
Using command pecl might fail due to /tmp mounted with noexec, and still you can use it, if you are familiar with it. Here will I describe how I do it myself.
Most of PECL extensions will require that you install a devel package of a corresponding library from an OS repository. Use yum/rpm on CentOS and apt/apt-get on Debian/Ubuntu for this.
UPDATE, December 18, 2018: Here you can find a script: https://help.poralix.com/articles/install-pecl-extension-for-php-directadmin-server which will automate some processes.
In the following example we will install a PECL extension ssh2 for PHP 5.6. As a requirement you should install libssh2-devel on CentOS, on Debian/Ubuntu its name might differ, find it with apt-cache and install it.
export PHP_VER=56 export PECL_EXT=ssh2
Replace 56 with the desired PHP version without dots, example: 53 for PHP 5.3, 54 for PHP 5.4, 55 for PHP 5.5.
set it to 70 for PHP 7.0:
export PHP_VER=70
set it to 71 for PHP 7.1:
export PHP_VER=71
set it to 72 for PHP 7.2:
export PHP_VER=72
Replace ssh2 with a name of the desired PECL extension, example: apc
export PECL_EXT=apc
redis:
export PECL_EXT=redis
memcached:
export PECL_EXT=memcached
imagick:
export PECL_EXT=imagick
and so on.
The most simple way would be to run the following commands:
cd /usr/local/src /usr/local/php${PHP_VER}/bin/pecl channel-update pecl.php.net /usr/local/php${PHP_VER}/bin/pecl download ${PECL_EXT}
You can download an extension by any other suitable mean. Unpack it and change directory to it:
tar -zxvf ${PECL_EXT}-*.tgz && cd ${PECL_EXT}-*/
/usr/local/php${PHP_VER}/bin/phpize
If "phpize" fails you should stop following the guide and fix the error before going further.
./configure --with-php-config=/usr/local/php${PHP_VER}/bin/php-config
If "configure" fails you should stop following the guide and fix the error before going further.
make && make install
If "make" fails you should stop following the guide and fix the error before going further.
echo "extension=${PECL_EXT}.so" >> /usr/local/php${PHP_VER}/lib/php.conf.d/90-custom.ini
Restart Apache, PHP-FPM for changes to take effect.
Now test whether or not the extension gets loaded into PHP, run the following command and see what it outputs:
/usr/local/php${PHP_VER}/bin/php -m | grep ${PECL_EXT} -c
1 as a result is a signal that the extension was successfully installed and initiated in PHP.
And unset the vars:
unset PHP_VER unset PECL_EXT
Another short example of installing PECL extension geoip (both for CentOS and Debian/Ubuntu):
[ -x "/usr/bin/yum" ] && yum -y install GeoIP-devel [ -x "/usr/bin/apt-get" ] && apt-get -y install libgeoip-dev export PHP_VER=56 export PECL_EXT=geoip cd /usr/local/src /usr/local/php${PHP_VER}/bin/pecl channel-update pecl.php.net /usr/local/php${PHP_VER}/bin/pecl download ${PECL_EXT} tar -zxvf ${PECL_EXT}-*.tgz && cd ${PECL_EXT}-*/ /usr/local/php${PHP_VER}/bin/phpize ./configure --with-php-config=/usr/local/php${PHP_VER}/bin/php-config make && make install echo "extension=${PECL_EXT}.so" >> /usr/local/php${PHP_VER}/lib/php.conf.d/90-custom.ini unset PHP_VER unset PECL_EXT
Restart Apache, PHP-FPM for changes to take effect.
That's it!