尝试在 mac OS 狮子上的 MAMP 中使用 PECL 安装 OAUTH 时遇到问题


Having problems while try to install OAUTH with PECL in MAMP on mac OS lion

我是设置 PHP 服务器的新手,并且我浏览了其他相关帖子,似乎没有人遇到与我相同的错误。我正在使用 MAMP 2.0.2,并运行 PHP 5.3.6,我尝试使用以下命令在本地 MAMP 上安装 oAuth:

$ cd /Applications/MAMP/bin/php/php5.3.6/bin
$ ./pecl install oauth

但是,它返回这样的错误:

Notice: unserialize(): Error at offset 276 of 1133 bytes in Config.php on line 1050
ERROR: The default config file is not a valid config file or is corrupted.

发生了什么事情?PECL 捆绑在 MAMP 中,它应该开箱即用......

更新:

我在其他地方读到一篇文章,建议保存安装路径的配置文件的数据不正确,所以我更改了以下文件中的一些值:

/Applications/MAMP/bin/php/php5.3.6/conf/pear.conf

然后,我使用以下命令:

$ ./pecl install oauth

开始下载和解压缩,但是当它尝试安装时,它会给出:

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/libtool --mode=compile cc  -I. -I/private/tmp/pear/temp/oauth -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/include -I/private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/main -I/private/tmp/pear/temp/oauth -I/Applications/MAMP/bin/php/php5.3.6/include/php -I/Applications/MAMP/bin/php/php5.3.6/include/php/main -I/Applications/MAMP/bin/php/php5.3.6/include/php/TSRM -I/Applications/MAMP/bin/php/php5.3.6/include/php/Zend -I/Applications/MAMP/bin/php/php5.3.6/include/php/ext -I/Applications/MAMP/bin/php/php5.3.6/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2 -Wall -g   -c /private/tmp/pear/temp/oauth/oauth.c -o oauth.lo
mkdir .libs
cc -I. -I/private/tmp/pear/temp/oauth -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/include -I/private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/main -I/private/tmp/pear/temp/oauth -I/Applications/MAMP/bin/php/php5.3.6/include/php -I/Applications/MAMP/bin/php/php5.3.6/include/php/main -I/Applications/MAMP/bin/php/php5.3.6/include/php/TSRM -I/Applications/MAMP/bin/php/php5.3.6/include/php/Zend -I/Applications/MAMP/bin/php/php5.3.6/include/php/ext -I/Applications/MAMP/bin/php/php5.3.6/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -Wall -g -c /private/tmp/pear/temp/oauth/oauth.c  -fno-common -DPIC -o .libs/oauth.o
In file included from /private/tmp/pear/temp/oauth/oauth.c:14:
/private/tmp/pear/temp/oauth/php_oauth.h:20:10: 
fatal error: 'php.h' file not found
include "php.h"
     ^
1 error generated.
make: *** [oauth.lo] Error 1
ERROR: `make' failed

再说一遍,发生了什么?

我知道

这很旧,但我在遇到类似问题时发现了这个问题。

MAMP没有附带一堆PHP源代码

  • 下载 MAMP 组件并配置
  • 网址:http://www.mamp.info/en/downloads/index.html(即MAMP_components_2.0.2.zip(
  • 解压缩您的 MAMP_components_2.0.2.zip
  • 识别您的 php-5.x.x.tar.gz 文件(其中 5.x.x 是您的 PHP 版本(
  • 如果您使用的是 php> 5.4.10,请从 http://php.net/releases 下载源代码,因为它们不在 MAMP 组件下载中(注释中的信用 pulkitsinghal(
  • 为您的 PHP 源代码创建目录:

    mkdir -vp /Applications/MAMP/bin/php5/include

  • Untar php-5.x.x.tar.gz into/Applications/MAMP/bin/php/php5.*/include 或/Applications/MAMP/bin/php5/include:

    tar zxvf php-5.x.x.tar.gz -C /Applications/MAMP/bin/php/php5.?.??/include

  • 将 php-5.x.x 目录重命名为 php(不带版本号(:

    mv /Applications/MAMP/bin/php/php5.2.17/include/php-5.?.?? /Applications/ MAMP/bin/php/php5.2.17/include/php

  • 配置 PHP 源代码(它将创建必要的文件,即 zend_config.h、tsrm_config.h 等(:

    cd /Applications/MAMP/bin/php/php5.?.??/include/php

    ./configure

该过程是另一个修复程序,但这解决了找不到php.h的问题

感谢我在哪里找到答案 - :

托马斯·亨特博客

谷歌文档详细流程

我在尝试使用 MAMP pecl install -f ssh2时遇到了同样的问题。

这是我修复它的方法:

  1. MAMP 不提供 PHP 5.4.10 的源代码存档,因此请从 php.net
  2. 下载
  3. 将源代码存档解压缩到/Applications/MAMP/bin/php/php5.4.10/include/php
  4. 运行./configure以配置平台的源代码(如果没有此步骤,pecl 安装将无法查找一堆头文件(
  5. 重试pecl安装

(非常感谢斯蒂芬的回答,这几乎是一样的(

这是对斯蒂芬的回答和格雷格评论的补充

在OSX 5.6.2上为php 5.6.2编译xdebug 2.3.2 10.10.2时,我无法摆脱

找不到"zend_config.h"文件

错误,直到我在 php 文件夹中将以下选项添加到 ./configure 中:

./配置 --without-iconv

致卡梅隆·布朗宁

PECL 模块是编译模块,为了安装它们,您需要 PHP 标头。您可以在 php.net/downloads.php 上找到标题,以确保下载与您的PHP版本匹配的版本。然后你可以按照这个操作:在 MAMP 环境中安装 PHP OAuth