【问题标题】:Upgrading PHP pear and pecl升级 PHP pear 和 pecl
【发布时间】:2016-01-21 06:36:12
【问题描述】:

我正在使用 Amazon 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 安装模块。我该怎么做?

【问题讨论】:

  • 你用 Yum 安装了 pecl 吗?大多数 pecl 包都在 Yum 中分发……使用 AWS Linux,您甚至可以使用 IUS Repos 来获得更多 PHP 扩展。 iuscommunity.org 我会清除通过 pecl CL​​I 安装的所有 pecl 扩展并使用 Yum...如果通过 Yum 安装 PHP,它们将与您的 PHP 版本一致
  • 我用的是百胜。正如我在编辑中提到的,有两个版本的 php.ini。如何使用 PHP 5.4 配置和安装 pear 和 pecl,然后尝试安装模块。
  • 我会删除其中一个 php 安装...您要安装的模块是什么?
  • 我正在尝试安装gearman.org
  • 这不是一个编程问题,因此这里是题外话。也就是说,设置一台新机器并安装了最近的 PHP,而不是很久没有收到 安全更新 的机器。然后,将您的基础架构迁移到新机器上,最后回收旧机器(如果新机器正常)。

标签: php pear pecl


【解决方案1】:

我最后用 yum 去掉了梨

sudo yum -y remove php-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

【讨论】:

    【解决方案2】:

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

    export PHP_PEAR_PHP_BIN=/usr/local/bin/php
    

    【讨论】:

      【解决方案3】:

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

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

      pear config-show
      

      将信息复制并保存到某处后,进行更改:

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

      【讨论】:

      • 谢谢。我按照你说的做了,但是 pear -V 仍然显示 PHP Version: 5.3.29
      猜你喜欢
      • 2020-04-24
      • 2012-07-15
      • 2010-11-26
      • 2012-01-12
      • 2018-10-25
      • 2012-02-15
      • 1970-01-01
      • 2013-02-21
      • 2017-05-06
      相关资源
      最近更新 更多