Search code examples
phppearpecl

Upgrading PHP pear and pecl


I am using Amazon Linux AMI. I have PHP5.4 installed.

php -v

gives

PHP 5.4.13 (cli) (built: Mar 29 2013 20:29:42) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

when I do pear -V

PEAR Version: 1.10.1
PHP Version: 5.3.29
Zend Engine Version: 2.3.0
Running on: Linux ip-10-0-1-160 4.1.7-15.23.amzn1.x86_64 #1 SMP Mon Sep 14 23:20:33 UTC 2015 x86_64

and pecl -V gives

PEAR Version: 1.10.1
PHP Version: 5.3.29
Zend Engine Version: 2.3.0
Running on: Linux ip-10-0-1-160 4.1.7-15.23.amzn1.x86_64 #1 SMP Mon Sep 14 23:20:33 UTC 2015 x86_64

My question is the PHP versions shown in pear and pecl command are different from php -v

When I install another module using pecl <module>, it gives

Warning: PHP Startup: <module>: Unable to initialize module
Module compiled with module API=20090626
PHP    compiled with module API=20100525

EDIT

I found out that there are two php installations

/usr/bin/php -v gives

PHP 5.3.29 (cli) (built: May 12 2015 22:42:19) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies

and

/usr/local/bin/php -v gives

PHP 5.4.13 (cli) (built: Mar 29 2013 20:29:42) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

I want to use the PHP 5.4 version and install modules using pear and pecl. How can I do that?


Solution

  • I ended up removing pear using yum

    sudo yum -y remove php-pear
    

    I then installed pear this way

    wget http://pear.php.net/go-pear.phar
    /usr/local/bin/php -q php-phar
    

    Now pear -V shows

    PEAR Version: 1.10.1
    PHP Version: 5.4.13