php 尝试在 Mac OS Lion 上的 MAMP 中使用 PECL 安装 OAUTH 时遇到问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10717752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 22:53:19  来源:igfitidea点击:

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

phpoauthmamppecl

提问by David Chen

i am new to setting php servers, and i had go though other related post, seems like nobody have the same error as i have. I am using MAMP 2.0.2, and running PHP 5.3.6, and I was trying to install oAuth on my local MAMP, using following commands:

我是设置 php 服务器的新手,我看过其他相关的帖子,似乎没有人有和我一样的错误。我正在使用 MAMP 2.0.2,并运行 PHP 5.3.6,并且我尝试使用以下命令在本地 MAMP 上安装 oAuth:

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

however, it return such error:

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

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.

What is happening? PECL is bundled in MAMP, which should be working out of the box....

怎么了?PECL 捆绑在 MAMP 中,它应该是开箱即用的......

Update:

更新:

I read a post elsewhere suggest that the config file's data, which holds the install paths are in-correct, so i changed some value in the following file :

我在别处读过一篇文章,表明保存安装路径的配置文件数据不正确,因此我更改了以下文件中的一些值:

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

Then, i use the command:

然后,我使用命令:

$ ./pecl install oauth

Which it starts download and unpack, but when it try to install, it gives:

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

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

Again, what is happening?

再次,发生了什么?

回答by Stephen

I know this is old but I found this question while having a similar issue.

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

MAMP doesn't ship with a bunch of the PHP sources

MAMP 没有附带一堆 PHP 源代码

  • Download MAMP components and configure
  • URL: http://www.mamp.info/en/downloads/index.html(i.e. MAMP_components_2.0.2.zip)
  • Unpack your MAMP_components_2.0.2.zip
  • Identify your php-5.x.x.tar.gz file (where 5.x.x is your version of PHP)
  • If you are using php > 5.4.10 then download the sources from http://php.net/releasesas they are not in the MAMP components download (credit pulkitsinghal in comments)
  • Create directory for your PHP sources:

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

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

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

  • Rename your php-5.x.x directory to php (without the version numbering):

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

  • Configure PHP sources (it'll create necessary files i.e. zend_config.h, tsrm_config.h, etc.):

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

    ./configure

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

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

  • 将 php-5.xxtar.gz 解压到 /Applications/MAMP/bin/php/php5.*/include 或 /Applications/MAMP/bin/php5/ 包括:

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

  • 将您的 php-5.xx 目录重命名为 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

The process was for another fix but this resolved the issues with php.h not being found

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

Credit to where I found the answers - :

归功于我找到答案的地方 - :

Thomas Hunter Blog

托马斯·亨特博客

Google Doc detailing process

谷歌文档详解流程

回答by James Newell

I had the same problem whilst trying to pecl install -f ssh2with MAMP.

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

Here's how I fixed it:

这是我修复它的方法:

  1. MAMP doesn't provide the source code archive for PHP 5.4.10 so download it from php.net
  2. Extract the source code archive to /Applications/MAMP/bin/php/php5.4.10/include/php
  3. Run ./configureto configure the source code for your platform (without this step the pecl install will fail looking for a bunch of header files)
  4. Retry your peclinstall
  1. MAMP 不提供 PHP 5.4.10 的源代码存档,因此请从php.net下载
  2. 将源代码存档解压缩到 /Applications/MAMP/bin/php/php5.4.10/include/php
  3. 运行./configure为您的平台配置源代码(如果没有这一步,pecl 安装将无法查找一堆头文件)
  4. 重试pecl安装

(much thanks to Stephen's answer which is pretty much the same)

(非常感谢斯蒂芬的回答几乎相同)

回答by beniguet

This is a complement to Stephen's answer and Greg's comment

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

When compiling xdebug 2.3.2 for php 5.6.2 on OSX 10.10.2, I could not get rid of the

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

'zend_config.h' file not found

找不到“zend_config.h”文件

error until I added the following option to ./configure in the php folder:

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

./configure --without-iconv

./configure --without-iconv

Credits to Cameron Browning

归功于卡梅伦布朗宁

回答by sonique

PECL Modules are compiled modules, in order to install them, you need the PHP headers. You can found the headers on php.net/downloads.php make sure you download a version which match with your PHP version. Then you can follow this : Installing PHP OAuth in MAMP environment

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