Install PECL extension for PHP an easy way

Installation of PECL extensions for PHP can be done an easy way. Learn here how to do it in a server console as a superuser root.

Let's Start

First, connect to a Directadmin server as root.

Then download a script:

cd /usr/local/directadmin/scripts/custom
wget https://raw.githubusercontent.com/poralix/directadmin-utils/master/php/php-extension.sh -O php-extension.sh
chmod 750 php-extension.sh
./php-extension.sh

If succeeded you will see the script usage (the current 0.7-beta version output):

Usage:

./php-extension.sh <command> <pecl_extension> [<options>]

        Supported commands:

            install   - to install extension
            remove    - to remove extension
            status    - show status of an extension

        options:

            --ver=VER - to install a specified version of an extension

            --beta    - to install a beta version of an extension

            --php=VER - to install extension for one PHP version
                        digits only (only one version at a time):
                        52, 53, 54, 55, 56, 70, 71, 72, 73, etc

 

So now we can install PECL extensions. Please note in certain cases you will need to install dependencies, for example.

PHP and GeoIP

If you want to install a GeoIP extension for PHP you will need first install GeoIP-devel and GeoIP packages (according to CentOS names), then you can run:

./php-extension.sh install geoip

You can check installation status with the following command:

./php-extension.sh status geoip

Run the command if you want to remove the extension:

./php-extension.sh remove geoip

PHP and memcached

For memcached extension you will need to install memcachedmemcached-devellibmemcached-devellibmemcached packages (according to CentOS names), then run:

./php-extension.sh install memcached

You can check installation status with the following command:

./php-extension.sh status memcached

Run the command if you want to remove the extension:

./php-extension.sh remove memcached

PHP and Redis

 For redis extension you will need to install redis

./php-extension.sh install redis

You can check installation status with the following command:

./php-extension.sh status redis

Run the command if you want to remove the extension:

./php-extension.sh remove redis

If you check the status now you should see:

# ./php-extension.sh status redis
[Warning] The extension redis for PHP 56 not found!
[Warning] The extension redis for PHP 72 not found!

Important

And so on. The script does not provide details on why an installation fails, so if an installation fails you still will need to read its output.

I hope the script will make it easier installing of PECL extensions for PHP on your servers. 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to reinstall DirectAdmin in your web server?

Run the following commands to install: cd /usr/local/directadmin./directadmin i./directadmin p

How to install imagick with custombuild of DA?

Run the following command: cd /usr/local/directadmin/custombuild ./build update ./build...

The service ‘exim’ on server xxx is currently down

Rebuild your exim. cd /usr/local/directadmin/custombuild./build update./build set exim...

Change DA port to your choice where CSF installed

Here I will show you how to change the port from 2222 to 9999 in two steps. Step One:...

How to migrate cPanel account to DirectAdmin?

The cPanel conversion script currently only works for Admin Level restores. You must have to be...