升级 PHP pear 和 pecl

Upgrading PHP pear and pecl

我正在使用亚马逊 Linux AMI。我安装了 PHP5.4。

php -v

给予

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

当我做 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

pecl -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

我的问题是 pearpecl 命令中显示的 PHP 版本与 php -v

不同

当我使用 pecl <module> 安装另一个模块时,它给出

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

编辑

我发现有两个php安装

/usr/bin/php -v 给出

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

/usr/local/bin/php -v 给出

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

我想使用 PHP 5.4 版本并使用 pear 和 pecl 安装模块。我该怎么做?

你应该可以通过告诉 PEAR 使用 5.4 版本的 PHP 来完成这个...也许试试这个:

首先,记下所有当前设置,以防您需要回滚:

pear config-show

复制并保存该信息后,进行更改:

pear config-set php_bin /usr/local/bin/php

在您的 .bashrc(如果您不使用 bash,则为等效项),您需要设置一个名为 PHP_PEAR_PHP_BIN 的环境变量到 php 您要使用的二进制文件:

export PHP_PEAR_PHP_BIN=/usr/local/bin/php

我最终使用 yum 删除了 pear

sudo yum -y remove php-pear

然后我就这样安装了pear

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

现在pear -V显示

PEAR Version: 1.10.1
PHP Version: 5.4.13