How to Install PECL and phpize on Ubuntu

How to install PECL and phpize on Ubuntu server

 

I got the below error while trying to install a PHP extension on an ubuntu server. The error shows phpize is not installed on the server.

 

running: phpize
sh: 1: phpize: not found
ERROR: `phpize' failed


 


 

Install phpize on Ubuntu server 16.04

1. You should log into your Ubuntu server as root user or login as any user with sudo privileges.

2. You can use ‘apt-file’ command to find the package that provide phpize


 

apt-file search /usr/bin/phpize
php7.0-dev: /usr/bin/phpize7.0


 

above command shows ‘phpize7.0’ is provided by PHP7.0-dev package. You can install this package using apt.

3. Run the command ‘apt-get install [versionofphp]-dev’ to install

For PHP version 7.0 run : apt-get install php7.0-dev

For PHP version 7.1 run : apt-get install php7.1-dev

4. Now phpize is installed. Execute the command ‘/usr/bin/phpize7.0 –version’ to check the version.

 


 

Steps to install PECL on Ubuntu 16.04

PECL (PHP Extension Community Library) is a repository for PHP extensions. PECL command is used to install PECL extensions.

1. Log into your Ubuntu server as ‘root’ user or login as any user with sudo privileges

2. Using ‘apt-file search’ command you can find the package which provide pecl.

 

# apt-file search /usr/bin/pecl
php-pear: /usr/bin/pecl

 

The above command output shows pecl is provided by ‘php-pear’ package.

3. Install php-pear package using apt.

command to install php-pear : apt install php-pear

4. Run the command ‘pecl version’ to show version information.

 

# pecl version
PEAR Version: 1.10.1
PHP Version: 7.0.32-0ubuntu0.16.04.1
Zend Engine Version: 3.0.0
Running on: Linux ip-172-31-34-159 4.4.0-1074-aws #84-Ubuntu SMP Thu Dec 6 08:57:58 UTC 2018 x86_64